gameServer/hedgewars-server.hs
changeset 2867 9be6693c78cb
parent 2349 ba7a0813c532
child 3425 ead2ed20dfd4
equal deleted inserted replaced
2866:450ca0afcd58 2867:9be6693c78cb
    24 import System.Posix
    24 import System.Posix
    25 #endif
    25 #endif
    26 
    26 
    27 
    27 
    28 setupLoggers =
    28 setupLoggers =
    29 	updateGlobalLogger "Clients"
    29     updateGlobalLogger "Clients"
    30 		(setLevel INFO)
    30         (setLevel INFO)
    31 
    31 
    32 main = withSocketsDo $ do
    32 main = withSocketsDo $ do
    33 #if !defined(mingw32_HOST_OS)
    33 #if !defined(mingw32_HOST_OS)
    34 	installHandler sigPIPE Ignore Nothing;
    34     installHandler sigPIPE Ignore Nothing;
    35 	installHandler sigCHLD Ignore Nothing;
    35     installHandler sigCHLD Ignore Nothing;
    36 #endif
    36 #endif
    37 
    37 
    38 	setupLoggers
    38     setupLoggers
    39 
    39 
    40 	stats <- atomically $ newTMVar (StatisticsInfo 0 0)
    40     stats <- atomically $ newTMVar (StatisticsInfo 0 0)
    41 	dbQueriesChan <- newChan
    41     dbQueriesChan <- newChan
    42 	coreChan <- newChan
    42     coreChan <- newChan
    43 	serverInfo' <- getOpts $ newServerInfo stats coreChan dbQueriesChan
    43     serverInfo' <- getOpts $ newServerInfo stats coreChan dbQueriesChan
    44 	
    44     
    45 #if defined(OFFICIAL_SERVER)
    45 #if defined(OFFICIAL_SERVER)
    46 	dbHost' <- askFromConsole "DB host: "
    46     dbHost' <- askFromConsole "DB host: "
    47 	dbLogin' <- askFromConsole "login: "
    47     dbLogin' <- askFromConsole "login: "
    48 	dbPassword' <- askFromConsole "password: "
    48     dbPassword' <- askFromConsole "password: "
    49 	let serverInfo = serverInfo'{dbHost = dbHost', dbLogin = dbLogin', dbPassword = dbPassword'}
    49     let serverInfo = serverInfo'{dbHost = dbHost', dbLogin = dbLogin', dbPassword = dbPassword'}
    50 #else
    50 #else
    51 	let serverInfo = serverInfo'
    51     let serverInfo = serverInfo'
    52 #endif
    52 #endif
    53 
    53 
    54 	Exception.bracket
    54     Exception.bracket
    55 		(Network.listenOn $ Network.PortNumber $ listenPort serverInfo)
    55         (Network.listenOn $ Network.PortNumber $ listenPort serverInfo)
    56 		sClose
    56         sClose
    57 		(startServer serverInfo)
    57         (startServer serverInfo)