Fork me on GitHub
Ian Fernandez23:01:11

Saw this in some code:

shutdown-sigterm   (.addShutdownHook
                            (Thread. ^Runnable (fn []
                                                 (log/fatal "Triggered shutdown via SIGTERM")
                                                 (a/>!! shutdown-trigger-channel {:meta :sigterm})
                                                 ;; put message into shutdown trigger channel then
                                                 ;; block until shutdown-complete
                                                 (a/<!! shutdown-complete-channel))))
Is that even makes a sense? this .addShutdownHook?

Ian Fernandez23:01:00

this is inside of a function inside a let

Ian Fernandez23:01:29

that means that when the function finishes to run, it tries to shutdown the system?

Ian Fernandez23:01:37

is it needed for core-async?


there is a general class of things, shutdown hooks, object finalizers (I would throw default exception handlers on here, but it is not exactly the same thing) that to the naive seem like they solve problems by making it easy to do things to clean things up.

👍 1

but in general they just muddy the waters and make "shutting down" or "cleaning up" a very complicated multiphased process

👍 1