gameServer/hedgewars-server.hs
changeset 3425 ead2ed20dfd4
parent 2867 9be6693c78cb
child 3435 4e4f88a7bdf2
equal deleted inserted replaced
3424:5543340db663 3425:ead2ed20dfd4
     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
     6 import qualified Network
       
     7 import Control.Concurrent.STM
     6 import Control.Concurrent.STM
     8 import Control.Concurrent.Chan
     7 import Control.Concurrent.Chan
     9 #if defined(NEW_EXCEPTIONS)
     8 #if defined(NEW_EXCEPTIONS)
    10 import qualified Control.OldException as Exception
     9 import qualified Control.OldException as Exception
    11 #else
    10 #else
    13 #endif
    12 #endif
    14 import System.Log.Logger
    13 import System.Log.Logger
    15 -----------------------------------
    14 -----------------------------------
    16 import Opts
    15 import Opts
    17 import CoreTypes
    16 import CoreTypes
    18 import OfficialServer.DBInteraction
       
    19 import ServerCore
    17 import ServerCore
    20 import Utils
       
    21 
    18 
    22 
    19 
    23 #if !defined(mingw32_HOST_OS)
    20 #if !defined(mingw32_HOST_OS)
    24 import System.Posix
    21 import System.Posix
    25 #endif
    22 #endif
    26 
    23 
    27 
    24 
    28 setupLoggers =
    25 setupLoggers =
    29     updateGlobalLogger "Clients"
    26     updateGlobalLogger "Clients"
    30         (setLevel INFO)
    27         (setLevel DEBUG)
    31 
    28 
    32 main = withSocketsDo $ do
    29 main = withSocketsDo $ do
    33 #if !defined(mingw32_HOST_OS)
    30 #if !defined(mingw32_HOST_OS)
    34     installHandler sigPIPE Ignore Nothing;
    31     installHandler sigPIPE Ignore Nothing;
    35     installHandler sigCHLD Ignore Nothing;
    32     installHandler sigCHLD Ignore Nothing;
    36 #endif
    33 #endif
    37 
    34 
    38     setupLoggers
    35     setupLoggers
    39 
    36 
    40     stats <- atomically $ newTMVar (StatisticsInfo 0 0)
    37     stats' <- atomically $ newTMVar (StatisticsInfo 0 0)
    41     dbQueriesChan <- newChan
    38     dbQueriesChan <- newChan
    42     coreChan <- newChan
    39     coreChan' <- newChan
    43     serverInfo' <- getOpts $ newServerInfo stats coreChan dbQueriesChan
    40     serverInfo' <- getOpts $ newServerInfo stats' coreChan' dbQueriesChan
    44     
    41     
    45 #if defined(OFFICIAL_SERVER)
    42 #if defined(OFFICIAL_SERVER)
    46     dbHost' <- askFromConsole "DB host: "
    43     dbHost' <- askFromConsole "DB host: "
    47     dbLogin' <- askFromConsole "login: "
    44     dbLogin' <- askFromConsole "login: "
    48     dbPassword' <- askFromConsole "password: "
    45     dbPassword' <- askFromConsole "password: "