I’m creating a Happstack server application, but I don’t know how to end the application .
If I have:
main = do
printf "begin server"
simpleHTTP nullConf myHomepage
printf "end server"
I can run it ok, and I can kill the application (linux) with CTRL+C, but the last print is never executed. How can I exit gracefully from Happstack? It bothers me because I notice that eventlog is not generated if I don’t exit correctly from the application.
UPDATE:
The application is using Dyre at the top main.
I generally use
forkIOto spawnsimpleHTTPin a separate thread. And thenwaitForTerminationto wait for^C.waitForTerminationcomes from thehappstack-statepackage. It really needs to be moved somewhere else for multiple reasons. If you don’t want to installhappstack-stateyou can copy and paste a local copy into your app: