From d31b940c50f6cbdcd714b5155946390d7c20ba51 Mon Sep 17 00:00:00 2001 From: Keagan McClelland Date: Mon, 30 Nov 2020 20:22:25 -0700 Subject: [PATCH] sleep before looping --- agent/src/Application.hs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/agent/src/Application.hs b/agent/src/Application.hs index 01d24c2df..898d11951 100644 --- a/agent/src/Application.hs +++ b/agent/src/Application.hs @@ -19,6 +19,7 @@ module Application , handler , runDb , getAgentCtx + , sleep ) where @@ -189,7 +190,7 @@ startupSequence foundation = do withAgentVersionLog_ "App notifications refreshing" 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" -- reloading avahi daemon @@ -204,6 +205,10 @@ startupSequence foundation = do withAgentVersionLog_ "Listening for Self-Update Signal" 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) --------------------------------------------------------------