I've been working on a pixel server built using Haskell Warp and have been struggling to work out how to run it in daemonized mode.
Warp works great - I can use run
from Network.Wai.Handler.Warp to serve HTTP, runTLS
from Network.Wai.Handler.WarpTLS to serve HTTPS, and I can run both by spawning a new thread:
startBoth :: Config -> IO ()
startBoth config = do
_ <- forkIO $ startHTTPS config
startHTTP config
My problem is figuring out how to use detachDaemon from MissingH (System.Daemon) to get my server detached and running in the background on Ubuntu.
In my Main.hs I've tried adding a detachDaemon
action like so:
main :: IO ()
main =
detachDaemon >> cmdArgs options >>= getConfig . optionsConfig >>= start
but the program then just silently exits without error, and without anything showing up when I run ps -ef | grep snowhuskyd
.
How should I be using detachDaemon
- is it even possible with Warp? I can't find a single example of using detachDaemon
on the Web - any help would be gratefully received!