Safe Haskell | Safe-Infered |
---|
Implementation of the generic daemon functionality.
- devNull :: FilePath
- daemonStartupErr :: String -> String
- data DaemonOptions = DaemonOptions {
- optShowHelp :: Bool
- optShowVer :: Bool
- optShowComp :: Bool
- optDaemonize :: Bool
- optPort :: Maybe Word16
- optDebug :: Bool
- optNoUserChecks :: Bool
- optBindAddress :: Maybe String
- optSyslogUsage :: Maybe SyslogUsage
- defaultOptions :: DaemonOptions
- type OptType = GenericOptType DaemonOptions
- type CheckFn a = DaemonOptions -> IO (Either ExitCode a)
- type PrepFn a b = DaemonOptions -> a -> IO b
- type MainFn a b = DaemonOptions -> a -> b -> IO ()
- oNoDaemonize :: OptType
- oDebug :: OptType
- oNoUserChecks :: OptType
- oPort :: Int -> OptType
- oBindAddress :: OptType
- oSyslogUsage :: OptType
- genericOpts :: [OptType]
- ioErrorToResult :: String -> IOError -> IO (Result a)
- parseArgs :: String -> [OptType] -> IO (DaemonOptions, [String])
- pidFileMode :: FileMode
- pidFileFlags :: OpenFileFlags
- writePidFile :: FilePath -> IO Fd
- cleanupSocket :: FilePath -> IO ()
- setupDaemonEnv :: FilePath -> FileMode -> IO ()
- finalCleanup :: FilePath -> IO ()
- handleSigTerm :: ThreadId -> IO ()
- handleSigHup :: FilePath -> IO ()
- setupDaemonFDs :: Maybe FilePath -> IO ()
- defaultBindAddr :: Int -> Family -> Result (Family, SockAddr)
- parseAddress :: DaemonOptions -> Int -> IO (Result (Family, SockAddr))
- vClusterHostNameEnvVar :: String
- getFQDN' :: Maybe AddrInfo -> IO String
- getFQDNwithHints :: Maybe AddrInfo -> IO String
- getFQDN :: IO String
- isMaster :: IO Bool
- ensureNode :: GanetiDaemon -> IO ()
- describeError :: String -> Maybe Handle -> Maybe FilePath -> IO a -> IO a
- daemonize :: FilePath -> (Maybe Fd -> IO ()) -> IO ()
- genericMain :: GanetiDaemon -> [OptType] -> CheckFn a -> PrepFn a b -> MainFn a b -> IO ()
- fullPrep :: GanetiDaemon -> DaemonOptions -> SyslogUsage -> a -> PrepFn a b -> IO (FilePath, b)
- innerMain :: GanetiDaemon -> DaemonOptions -> SyslogUsage -> a -> PrepFn a b -> MainFn a b -> Maybe Fd -> IO ()
- handlePrepErr :: Bool -> Maybe Fd -> IOError -> IO a
- maybeCloseFd :: Maybe Fd -> IO ()
Constants
daemonStartupErr :: String -> StringSource
Data types
data DaemonOptions Source
Command line options structure.
DaemonOptions | |
|
defaultOptions :: DaemonOptionsSource
Default values for the command line options.
type OptType = GenericOptType DaemonOptionsSource
Abrreviation for the option type.
type CheckFn a = DaemonOptions -> IO (Either ExitCode a)Source
Check function type.
type PrepFn a b = DaemonOptions -> a -> IO bSource
Prepare function type.
type MainFn a b = DaemonOptions -> a -> b -> IO ()Source
Main execution function type.
Command line options
genericOpts :: [OptType]Source
ioErrorToResult :: String -> IOError -> IO (Result a)Source
parseArgs :: String -> [OptType] -> IO (DaemonOptions, [String])Source
Small wrapper over getArgs and parseOpts
.
Daemon-related functions
pidFileMode :: FileModeSource
pidFileFlags :: OpenFileFlagsSource
writePidFile :: FilePath -> IO FdSource
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.
setupDaemonEnv :: FilePath -> FileMode -> IO ()Source
finalCleanup :: FilePath -> IO ()Source
handleSigTerm :: ThreadId -> IO ()Source
handleSigHup :: FilePath -> IO ()Source
setupDaemonFDs :: Maybe FilePath -> IO ()Source
defaultBindAddr :: Int -> Family -> Result (Family, SockAddr)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.
vClusterHostNameEnvVar :: StringSource
getFQDNwithHints :: Maybe AddrInfo -> IO StringSource
ensureNode :: GanetiDaemon -> IO ()Source
describeError :: String -> Maybe Handle -> Maybe FilePath -> IO a -> IO aSource
Run an I/O action that might throw an I/O error, under a handler that will simply annotate and re-throw the exception.
:: 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.
fullPrep :: GanetiDaemon -> DaemonOptions -> SyslogUsage -> a -> PrepFn a b -> IO (FilePath, b)Source
innerMain :: GanetiDaemon -> DaemonOptions -> SyslogUsage -> a -> PrepFn a b -> MainFn a b -> Maybe Fd -> IO ()Source
handlePrepErr :: Bool -> Maybe Fd -> IOError -> IO aSource
maybeCloseFd :: Maybe Fd -> IO ()Source