author | unc0rr |
Fri, 19 Jun 2009 18:01:48 +0000 | |
changeset 2174 | 9132de4acf05 |
parent 2129 | 8664554d5547 |
child 2296 | 19f2f76dc346 |
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; |
|
2129
8664554d5547
Another approach to zombies problem (set SIGCHLD handler to SIG_IGN)
unc0rr
parents:
1985
diff
changeset
|
31 |
installHandler sigCHLD Ignore Nothing; |
1804 | 32 |
#endif |
33 |
||
34 |
setupLoggers |
|
35 |
||
36 |
stats <- atomically $ newTMVar (StatisticsInfo 0 0) |
|
1833 | 37 |
dbQueriesChan <- newChan |
1804 | 38 |
coreChan <- newChan |
1964 | 39 |
serverInfo' <- getOpts $ newServerInfo stats coreChan dbQueriesChan |
1804 | 40 |
|
1964 | 41 |
#if defined(OFFICIAL_SERVER) |
42 |
dbHost' <- askFromConsole "DB host: " |
|
43 |
dbLogin' <- askFromConsole "login: " |
|
44 |
dbPassword' <- askFromConsole "password: " |
|
45 |
let serverInfo = serverInfo'{dbHost = dbHost', dbLogin = dbLogin', dbPassword = dbPassword'} |
|
46 |
#else |
|
47 |
let serverInfo = serverInfo' |
|
48 |
#endif |
|
49 |
||
1804 | 50 |
bracket |
51 |
(Network.listenOn $ Network.PortNumber $ listenPort serverInfo) |
|
52 |
(sClose) |
|
1927
e2031906a347
Ping clients every 30 seconds. Disconnection due to ping timeout to be implemented.
unc0rr
parents:
1839
diff
changeset
|
53 |
(startServer serverInfo) |