microservice-boilerplate
microservice-boilerplate copied to clipboard
Adds Gracefully Server Stop
Adds graceful stop
(defn -main
"The entry-point for 'gen-class'"
[& _args]
(start-system! (build-system-map))
; Graceful shutdown
(.addShutdownHook (Runtime/getRuntime)
(Thread. ^Runnable stop-system!)))
CC @lucascebertin
Maybe follow something like this: https://gist.github.com/mourjo/ff04b46070c54e37b63a19d8957c3fcd#file-ordered-shutdown-clj
The event addShutdownHook needs to be placed before (start-system! (build-system-map)).
Without this small fix, signaling are not handled properly because of the control flow blocked by the webserver.
(defn -main
"The entry-point for 'gen-class'"
[& _args]
; Graceful shutdown
(.addShutdownHook (Runtime/getRuntime) (Thread. ^Runnable stop-system!))
(start-system! (build-system-map)))