haskell - react to SIGTERM with yesod application -
when start yesod application, create connection rabbitmq server store in app
datatype access during requests. when deploy new version of app or restart server, want gracefully close connection. along lines of:
import system.posix.signals(sigterm, installhandler, handler(..)) appmain :: io () appmain = settings <- loadappsettingsargs [configsettingsymlvalue] useenv foundation <- makefoundation settings app <- makeapplication foundation --install shutdown handler here installhandler sigterm (catch (closeconnection (rabbitmqconn app))) nothing runsettings (warpsettings foundation) app
however if process won't exit @ all(and heroku send sigkill eventually.
import system.posix.signals(sigterm, installhandler, handler(..)) import system.exit(exitsuccess) appmain :: io () appmain = settings <- loadappsettingsargs [configsettingsymlvalue] useenv foundation <- makefoundation settings app <- makeapplication foundation --install shutdown handler here, time exit process after close connection installhandler sigterm (catch ((closeconnection $ rabbitmqconn conn) >> exitsuccess)) nothing runsettings (warpsettings foundation) app
however i'm worried might exit application , prevent other handlers running if in wrong place(and prevent gracefull shutdown of else). i'm wondering if there place in yesod app should adding type of code fit in rest of framework.
Comments
Post a Comment