Safe HaskellNone




Implementation of the generic daemon functionality.



Data types

data DaemonOptions Source #

Command line options structure.




defaultOptions :: DaemonOptions Source #

Default values for the command line options.

type OptType = GenericOptType DaemonOptions Source #

Abrreviation for the option type.

type CheckFn a = DaemonOptions -> IO (Either ExitCode a) Source #

Check function type.

type PrepFn a b = DaemonOptions -> a -> IO b Source #

Prepare function type.

type MainFn a b = DaemonOptions -> a -> b -> IO () Source #

Main execution function type.

Command line options

oPort :: Int -> OptType Source #

parseArgs :: String -> [OptType] -> IO (DaemonOptions, [String]) Source #

Small wrapper over getArgs and parseOpts.

Daemon-related functions

cleanupSocket :: FilePath -> IO () Source #

Helper function to ensure a socket doesn't exist. Should only be called once we have locked the pid file successfully.

parseAddress Source #


:: DaemonOptions

Command line options

-> Int

Default port for this daemon

-> IO (Result (Family, SockAddr)) 

Based on the options, compute the socket address to use for the daemon.

getFQDN :: IO String Source #

Return the full qualified host name, honoring the vcluster setup.

describeError :: String -> Maybe Handle -> Maybe FilePath -> IO a -> IO a Source #

Run an I/O action that might throw an I/O error, under a handler that will simply annotate and re-throw the exception.

genericMain Source #


:: GanetiDaemon

The daemon we're running

-> [OptType]

The available options

-> CheckFn a

Check function

-> PrepFn a b

Prepare function

-> MainFn a b

Execution function

-> IO () 

Generic daemon startup.