Skip to content

Commit

Permalink
Removed unneeded forkIO and waitForTermination.
Browse files Browse the repository at this point in the history
These are only needed if you need to do cleanup (or save state)
on exit, which we don't with the current system.
This will make it easier to write an init script.
  • Loading branch information
jgm committed Jun 17, 2009
1 parent 5704253 commit 3ef1d96
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 36 deletions.
29 changes: 0 additions & 29 deletions Network/Gitit/Server.hs
Expand Up @@ -33,7 +33,6 @@ module Network.Gitit.Server
, setContentType , setContentType
, setFilename , setFilename
, lookupIPAddr , lookupIPAddr
, waitForTermination
, module Happstack.Server , module Happstack.Server
, compressedResponseFilter , compressedResponseFilter
) )
Expand Down Expand Up @@ -84,31 +83,3 @@ lookupIPAddr hostname = do
then return Nothing then return Nothing
else return $ Just $ takeWhile (/=':') $ show $ addrAddress $ head addrs else return $ Just $ takeWhile (/=':') $ show $ addrAddress $ head addrs



-- mime types

-- Note: waitForTermination is copied from Happstack.State.Control
-- to avoid a dependency on happstack-state. (Shouldn't this
-- function be in happstack-server?)

-- | Wait for a signal.
-- On unix, a signal is sigINT or sigTERM. On windows, the signal
-- is entering 'e'.
waitForTermination :: IO ()
waitForTermination
= do
#ifdef UNIX
istty <- queryTerminal stdInput
mv <- newEmptyMVar
installHandler softwareTermination (CatchOnce (putMVar mv ())) Nothing
case istty of
True -> do installHandler keyboardSignal (CatchOnce (putMVar mv ())) Nothing
return ()
False -> return ()
takeMVar mv
#else
let loop 'e' = return ()
loop _ = getChar >>= loop
loop 'c'
#endif

8 changes: 1 addition & 7 deletions gitit.hs
Expand Up @@ -25,7 +25,6 @@ import Network.Gitit.Initialize (createStaticIfMissing, createRepoIfMissing)
import Prelude hiding (writeFile, readFile, catch) import Prelude hiding (writeFile, readFile, catch)
import System.Directory import System.Directory
import System.FilePath ((</>)) import System.FilePath ((</>))
import Control.Concurrent
import Network.Gitit.Config (getConfigFromOpts) import Network.Gitit.Config (getConfigFromOpts)
import Data.Maybe (isNothing) import Data.Maybe (isNothing)
import Control.Monad.Reader import Control.Monad.Reader
Expand Down Expand Up @@ -76,10 +75,5 @@ main = do


let serverConf = Conf { validator = Nothing, port = portNumber conf' } let serverConf = Conf { validator = Nothing, port = portNumber conf' }
-- start the server -- start the server
tid <- forkIO $ simpleHTTP serverConf $ wikiHandler conf' simpleHTTP serverConf $ wikiHandler conf'
waitForTermination

-- shut down the server
killThread tid



0 comments on commit 3ef1d96

Please sign in to comment.