blob: 1351ad55f7e559862bc88978fd444cf4c51c19d2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
module Daemon
( runDaemon
) where
import Control.Concurrent (threadDelay)
import Control.Monad (forever)
import Daemon.Frequency
runDaemon :: Frequency -> (() -> IO ()) -> IO ()
runDaemon frequency process =
forever $ do
process ()
threadDelay (sleepDelayMs frequency)
sleepDelayMs :: Frequency -> Int
sleepDelayMs Hourly = 1000000 * 60 * 60
sleepDelayMs Daily = (sleepDelayMs Hourly) * 24
|