gameServer/hedgewars-server.hs
changeset 4905 7842d085acf4
parent 4904 0eab727d4717
child 4921 2efad3acbb74
equal deleted inserted replaced
4904:0eab727d4717 4905:7842d085acf4
     1 {-# LANGUAGE CPP, ScopedTypeVariables #-}
     1 {-# LANGUAGE CPP, ScopedTypeVariables #-}
     2 
     2 
     3 module Main where
     3 module Main where
     4 
     4 
     5 import Network.Socket
     5 import Network.Socket
     6 import qualified Network
       
     7 import Network.BSD
     6 import Network.BSD
     8 import Control.Concurrent.STM
     7 import Control.Concurrent.STM
     9 import Control.Concurrent.Chan
     8 import Control.Concurrent.Chan
    10 #if defined(NEW_EXCEPTIONS)
       
    11 import qualified Control.OldException as Exception
       
    12 #else
       
    13 import qualified Control.Exception as Exception
     9 import qualified Control.Exception as Exception
    14 #endif
       
    15 import System.Log.Logger
    10 import System.Log.Logger
    16 -----------------------------------
    11 -----------------------------------
    17 import Opts
    12 import Opts
    18 import CoreTypes
    13 import CoreTypes
    19 import OfficialServer.DBInteraction
       
    20 import ServerCore
    14 import ServerCore
    21 import Utils
       
    22 
    15 
    23 
    16 
    24 #if !defined(mingw32_HOST_OS)
    17 #if !defined(mingw32_HOST_OS)
    25 import System.Posix
    18 import System.Posix
    26 #endif
    19 #endif
    27 
    20 
    28 
    21 
       
    22 setupLoggers :: IO ()
    29 setupLoggers =
    23 setupLoggers =
    30     updateGlobalLogger "Clients"
    24     updateGlobalLogger "Clients"
    31         (setLevel INFO)
    25         (setLevel INFO)
    32 
    26 
       
    27 main :: IO ()
    33 main = withSocketsDo $ do
    28 main = withSocketsDo $ do
    34 #if !defined(mingw32_HOST_OS)
    29 #if !defined(mingw32_HOST_OS)
    35     installHandler sigPIPE Ignore Nothing;
    30     installHandler sigPIPE Ignore Nothing;
    36     installHandler sigCHLD Ignore Nothing;
    31     installHandler sigCHLD Ignore Nothing;
    37 #endif
    32 #endif
    38 
    33 
    39     setupLoggers
    34     setupLoggers
    40 
    35 
    41     stats <- atomically $ newTMVar (StatisticsInfo 0 0)
    36     stats' <- atomically $ newTMVar (StatisticsInfo 0 0)
    42     dbQueriesChan <- newChan
    37     dbQueriesChan <- newChan
    43     coreChan <- newChan
    38     coreChan' <- newChan
    44     serverInfo' <- getOpts $ newServerInfo stats coreChan dbQueriesChan
    39     serverInfo' <- getOpts $ newServerInfo stats' coreChan' dbQueriesChan
    45     
    40 
    46 #if defined(OFFICIAL_SERVER)
    41 #if defined(OFFICIAL_SERVER)
    47     dbHost' <- askFromConsole "DB host: "
    42     dbHost' <- askFromConsole "DB host: "
    48     dbLogin' <- askFromConsole "login: "
    43     dbLogin' <- askFromConsole "login: "
    49     dbPassword' <- askFromConsole "password: "
    44     dbPassword' <- askFromConsole "password: "
    50     let serverInfo = serverInfo'{dbHost = dbHost', dbLogin = dbLogin', dbPassword = dbPassword'}
    45     let serverInfo = serverInfo'{dbHost = dbHost', dbLogin = dbLogin', dbPassword = dbPassword'}