gameServer/Actions.hs
changeset 5212 eaffb02f0053
parent 5211 8ebf92014447
child 5214 d2ad737891b0
equal deleted inserted replaced
5211:8ebf92014447 5212:eaffb02f0053
   466 
   466 
   467 
   467 
   468 processAction StatsAction = do
   468 processAction StatsAction = do
   469     si <- gets serverInfo
   469     si <- gets serverInfo
   470     when (not $ shutdownPending si) $ do
   470     when (not $ shutdownPending si) $ do
   471     rnc <- gets roomsClients
   471         rnc <- gets roomsClients
   472     (roomsNum, clientsNum) <- io $ withRoomsAndClients rnc st
   472         (roomsNum, clientsNum) <- io $ withRoomsAndClients rnc st
   473     io $ writeChan (dbQueries si) $ SendStats clientsNum (roomsNum - 1)
   473         io $ writeChan (dbQueries si) $ SendStats clientsNum (roomsNum - 1)
   474     where
   474     where
   475           st irnc = (length $ allRooms irnc, length $ allClients irnc)
   475           st irnc = (length $ allRooms irnc, length $ allClients irnc)
   476 
   476 
   477 processAction RestartServer = do
   477 processAction RestartServer = do 
   478     sock <- gets (fromJust . serverSocket . serverInfo)
   478     sp <- gets (shutdownPending . serverInfo)
   479     args <- gets (runArgs . serverInfo)
   479     when (not sp) $ do
   480     io $ do
   480         sock <- gets (fromJust . serverSocket . serverInfo)
   481         noticeM "Core" "Closing listening socket"
   481         args <- gets (runArgs . serverInfo)
   482         sClose sock
   482         io $ do
   483         noticeM "Core" "Spawning new server"
   483             noticeM "Core" "Closing listening socket"
   484         _ <- createProcess (proc "./hedgewars-server" args)
   484             sClose sock
   485         return ()
   485             noticeM "Core" "Spawning new server"
   486     processAction $ ModifyServerInfo (\s -> s{shutdownPending=True})
   486             _ <- createProcess (proc "./hedgewars-server" args)
       
   487             return ()
       
   488         processAction $ ModifyServerInfo (\s -> s{shutdownPending = True})
   487 
   489 
   488 processAction SaveReplay = do
   490 processAction SaveReplay = do
   489     ri <- clientRoomA
   491     ri <- clientRoomA
   490     rnc <- gets roomsClients
   492     rnc <- gets roomsClients
   491     io $ do
   493     io $ do