mirror of
https://github.com/simplex-chat/simplexmq.git
synced 2026-10-23 00:02:44 +00:00
1 parent
7e8e6c7e56
commit
2d5c026800
2 files changed
+1
-12
No files matched your search
@@ -258,7 +258,6 @@ library
|
||||
, time-manager ==0.0.*
|
||||
, tls >=1.7.0 && <1.8
|
||||
, transformers ==0.6.*
|
||||
, unix ==2.8.*
|
||||
, unliftio ==0.2.*
|
||||
, unliftio-core ==0.2.*
|
||||
, websockets ==0.12.*
|
||||
|
||||
@@ -186,9 +186,7 @@ import Simplex.RemoteControl.Client
|
||||
import Simplex.RemoteControl.Invitation
|
||||
import Simplex.RemoteControl.Types
|
||||
import System.Directory
|
||||
import System.Exit (exitSuccess)
|
||||
import System.Mem.Weak (deRefWeak)
|
||||
import System.Posix.Signals (Handler (Catch), installHandler, sigINT, sigTERM)
|
||||
import UnliftIO.Concurrent (forkFinally, forkIO, killThread, mkWeakThreadId, threadDelay)
|
||||
import qualified UnliftIO.Exception as E
|
||||
import UnliftIO.STM
|
||||
@@ -214,8 +212,6 @@ getSMPAgentClient_ clientId cfg initServers store backgroundMode =
|
||||
runAgentThreads c
|
||||
| backgroundMode = run c "subscriber" $ subscriber c
|
||||
| otherwise = do
|
||||
-- _ <- liftIO $ installHandler sigINT (Catch $ withAgentEnv' c $ handleSignal c) Nothing
|
||||
-- _ <- liftIO $ installHandler sigTERM (Catch $ withAgentEnv' c $ handleSignal c) Nothing
|
||||
restoreAgentStats c
|
||||
let threads =
|
||||
[ run c "subscriber" $ subscriber c,
|
||||
@@ -232,11 +228,6 @@ getSMPAgentClient_ clientId cfg initServers store backgroundMode =
|
||||
logError $ "Agent thread " <> name <> " crashed: " <> tshow e
|
||||
atomically $ writeTBQueue subQ ("", "", AEvt SAEConn $ ERR $ CRITICAL True $ show e)
|
||||
|
||||
handleSignal :: AgentClient -> AM' ()
|
||||
handleSignal c = do
|
||||
saveAgentStats c `E.catchAny` \e -> liftIO $ print $ "error saving agent stats: " <> tshow e
|
||||
liftIO exitSuccess
|
||||
|
||||
logAgentStats :: AgentClient -> AM' ()
|
||||
logAgentStats c = do
|
||||
let interval = 1000000 * 30 -- 30 seconds -- TODO config
|
||||
@@ -254,8 +245,7 @@ saveAgentStats AgentClient {smpServersStats, xftpServersStats} =
|
||||
xss <- readTVarIO xftpServersStats
|
||||
xftpServersStatsData <- mapM (atomically . getAgentXFTPServerStats) xss
|
||||
let stats = AgentPersistedServerStats {smpServersStatsData, xftpServersStatsData}
|
||||
-- logInfo $ "saving agent stats to file " <> T.pack f
|
||||
liftIO $ print $ "saving agent stats to file " <> T.pack f
|
||||
logInfo $ "saving agent stats to file " <> T.pack f
|
||||
B.writeFile f $ LB.toStrict $ J.encode stats
|
||||
-- logInfo "agent stats saved"
|
||||
liftIO $ print "agent stats saved"
|
||||
|
||||
Reference in new issue
Block a user