[Haskell-cafe] Shutting down a Yesod/warp application

Olaf Klinke olf at aatal-apotheke.de
Tue Apr 26 19:59:41 UTC 2022


Dear Cafe, 

this topic has been discussed [1,2] a decade ago. What is the current
state of affairs in this matter? It still seems to be addressed neither
in yesod nor warp [*]. 
We have two use cases: (1) A shutdown route that allows admins to
cleanly shut down the web application. (2) We want certain exceptions
to terminate the application and have the surrounding monitoring
(systemd, docker, ...) re-start the application. For (2) we are safe, I
think, because the worker threads are forked from the main thread [3]
calling warp, so propagating the exceptions up to the top bypasses warp
and yesod's very comprehensive exception handlers. But any exception
thrown while answering a request (such as (1)) is caught by default. 

Thanks
Olaf

[1] https://groups.google.com/g/yesodweb/c/VoenrabRUBQ
[2] https://stackoverflow.com/questions/7881327/how-do-i-implement-a-shutdown-command-in-a-wai-server
[3] https://mail.haskell.org/pipermail/haskell-cafe/2022-March/135132.html
[*] Warp offers setOnException and setOnExceptionResponse. But does re-
throwing certain exceptions from there terminate warp?



More information about the Haskell-Cafe mailing list