tickLeisteServer/app/Main.hs
2020-09-25 11:45:19 +02:00

49 lines
1.3 KiB
Haskell

module Main where
-- TODO:
-- We need some logic to compile with different backends. Right now we only
-- support warp. But a (fast) cgi backend would be nice too.
-- TODO:
-- We need some way too configure things, like the port we run on.
-- see Network.Wai.Handler.Warp.Settings and Network.Wai.Handler.Warp.runSettings
import Control.Concurrent.MVar
import WaiApp
import Control.Concurrent
#ifdef HTTP_SUPPORT
import qualified Network.Wai.Handler.Warp as HTTP
#endif
#ifdef HTTPS_SUPPORT
import qualified Network.Wai.Handler.WarpTLS as HTTPS
import qualified Network.Wai.Handler.Warp as HTTP
#endif
#ifdef FASTCGI_SUPPORT
import qualified Network.Wai.Handler.FastCGI as FastCGI
#endif
#ifdef CGI_SUPPORT
import qualified Network.Wai.Handler.CGI as CGI
#endif
-- we should add support for multiple backends (so we should fork them and
-- then wait till all of them terminated)
main :: IO ()
main = do
serverState <- newMVar newServerState
#ifdef HTTP_SUPPORT
HTTP.runSettings HTTP.defaultSettings $ waiApplication serverState
#endif
#ifdef HTTPS_SUPPORT
HTTPS.runTLS HTTPS.defaultTlsSettings HTTP.defaultSettings $ waiApplication serverState
#endif
#ifdef FASTCGI_SUPPORT
FastCGI.run $ waiApplication serverState
#endif
#ifdef CGI_SUPPORT
CGI.run $ waiApplication serverState
#endif
return ()