author | unc0rr |
Mon, 13 Apr 2009 13:03:57 +0000 | |
changeset 1991 | 24b5a3368ab6 |
parent 1985 | 0792e1485d07 |
child 2129 | 8664554d5547 |
permissions | -rw-r--r-- |
1804 | 1 |
{-# LANGUAGE CPP, ScopedTypeVariables, PatternSignatures #-} |
2 |
||
3 |
module Main where |
|
4 |
||
5 |
import Network.Socket |
|
6 |
import qualified Network |
|
7 |
import Control.Concurrent.STM |
|
8 |
import Control.Concurrent.Chan |
|
9 |
import Control.Exception |
|
10 |
import System.Log.Logger |
|
11 |
----------------------------------- |
|
12 |
import Opts |
|
13 |
import CoreTypes |
|
14 |
import OfficialServer.DBInteraction |
|
15 |
import ServerCore |
|
1964 | 16 |
import Utils |
1804 | 17 |
|
18 |
||
19 |
#if !defined(mingw32_HOST_OS) |
|
20 |
import System.Posix |
|
21 |
#endif |
|
22 |
||
23 |
||
24 |
setupLoggers = |
|
25 |
updateGlobalLogger "Clients" |
|
1985 | 26 |
(setLevel INFO) |
1804 | 27 |
|
28 |
main = withSocketsDo $ do |
|
29 |
#if !defined(mingw32_HOST_OS) |
|
30 |
installHandler sigPIPE Ignore Nothing; |
|
31 |
#endif |
|
32 |
||
33 |
setupLoggers |
|
34 |
||
35 |
stats <- atomically $ newTMVar (StatisticsInfo 0 0) |
|
1833 | 36 |
dbQueriesChan <- newChan |
1804 | 37 |
coreChan <- newChan |
1964 | 38 |
serverInfo' <- getOpts $ newServerInfo stats coreChan dbQueriesChan |
1804 | 39 |
|
1964 | 40 |
#if defined(OFFICIAL_SERVER) |
41 |
dbHost' <- askFromConsole "DB host: " |
|
42 |
dbLogin' <- askFromConsole "login: " |
|
43 |
dbPassword' <- askFromConsole "password: " |
|
44 |
let serverInfo = serverInfo'{dbHost = dbHost', dbLogin = dbLogin', dbPassword = dbPassword'} |
|
45 |
#else |
|
46 |
let serverInfo = serverInfo' |
|
47 |
#endif |
|
48 |
||
1804 | 49 |
bracket |
50 |
(Network.listenOn $ Network.PortNumber $ listenPort serverInfo) |
|
51 |
(sClose) |
|
1927
e2031906a347
Ping clients every 30 seconds. Disconnection due to ping timeout to be implemented.
unc0rr
parents:
1839
diff
changeset
|
52 |
(startServer serverInfo) |