sleep before looping

This commit is contained in:
Keagan McClelland
2020-11-30 20:22:25 -07:00
parent f1208f281c
commit d31b940c50

View File

@@ -19,6 +19,7 @@ module Application
, handler , handler
, runDb , runDb
, getAgentCtx , getAgentCtx
, sleep
) )
where where
@@ -189,7 +190,7 @@ startupSequence foundation = do
withAgentVersionLog_ "App notifications refreshing" withAgentVersionLog_ "App notifications refreshing"
withAgentVersionLog_ "Initializing SSL certificate renewal loop" withAgentVersionLog_ "Initializing SSL certificate renewal loop"
void . forkIO . forever $ forkIO $ SSLRenew.renewSslLeafCert foundation void . forkIO . forever $ forkIO $ SSLRenew.renewSslLeafCert foundation *> sleep 86_400
withAgentVersionLog_ "SSL Renewal daemon started" withAgentVersionLog_ "SSL Renewal daemon started"
-- reloading avahi daemon -- reloading avahi daemon
@@ -204,6 +205,10 @@ startupSequence foundation = do
withAgentVersionLog_ "Listening for Self-Update Signal" withAgentVersionLog_ "Listening for Self-Update Signal"
waitForUpdateSignal foundation waitForUpdateSignal foundation
sleep :: Integer -> IO ()
sleep n = let (full, r) = (n * 1_000_000) `divMod` (fromIntegral $ (maxBound :: Int)) in
replicateM_ (fromIntegral full) (threadDelay maxBound) *> threadDelay (fromIntegral r)
-------------------------------------------------------------- --------------------------------------------------------------
-- Functions for DevelMain.hs (a way to run the AgentCtx from GHCi) -- Functions for DevelMain.hs (a way to run the AgentCtx from GHCi)
-------------------------------------------------------------- --------------------------------------------------------------