ganeti-htoolsSource codeContentsIndex
Ganeti.Daemon
Contents
Constants
Data types
Command line options
Daemon-related functions
Description
Implementation of the generic daemon functionality.
Synopsis
devNull :: FilePath
data DaemonOptions = DaemonOptions {
optShowHelp :: Bool
optShowVer :: Bool
optDaemonize :: Bool
optPort :: Maybe Word16
optDebug :: Bool
optNoUserChecks :: Bool
optBindAddress :: Maybe String
optSyslogUsage :: Maybe SyslogUsage
}
defaultOptions :: DaemonOptions
type OptType = OptDescr (DaemonOptions -> Result DaemonOptions)
reqWithConversion :: (String -> Result a) -> (a -> DaemonOptions -> Result DaemonOptions) -> String -> ArgDescr (DaemonOptions -> Result DaemonOptions)
oShowHelp :: OptType
oShowVer :: OptType
oNoDaemonize :: OptType
oDebug :: OptType
oNoUserChecks :: OptType
oPort :: Int -> OptType
oBindAddress :: OptType
oSyslogUsage :: OptType
usageHelp :: String -> [OptType] -> String
parseOpts :: [String] -> String -> [OptType] -> IO (DaemonOptions, [String])
parseArgs :: String -> [OptType] -> IO (DaemonOptions, [String])
pidFileMode :: FileMode
pidFileFlags :: OpenFileFlags
_writePidFile :: FilePath -> IO Fd
formatIOError :: String -> IOError -> String
writePidFile :: FilePath -> IO (Result Fd)
setupDaemonEnv :: FilePath -> FileMode -> IO ()
handleSigHup :: FilePath -> IO ()
setupDaemonFDs :: Maybe FilePath -> IO ()
defaultBindAddr :: Int -> Family -> Result (Family, SockAddr)
resolveAddrHints :: Maybe AddrInfo
resolveAddr :: Int -> String -> IO (Result (Family, SockAddr))
parseAddress :: DaemonOptions -> Int -> IO (Result (Family, SockAddr))
daemonize :: FilePath -> IO () -> IO ()
genericMain :: GanetiDaemon -> [OptType] -> (DaemonOptions -> IO ()) -> IO ()
innerMain :: GanetiDaemon -> DaemonOptions -> SyslogUsage -> IO () -> IO ()
Constants
devNull :: FilePathSource
/dev/null path.
Data types
data DaemonOptions Source
Command line options structure.
Constructors
DaemonOptions
optShowHelp :: BoolJust show the help
optShowVer :: BoolJust show the program version
optDaemonize :: BoolWhether to daemonize or not
optPort :: Maybe Word16Override for the network port
optDebug :: BoolEnable debug messages
optNoUserChecks :: BoolIgnore user checks
optBindAddress :: Maybe StringOverride for the bind address
optSyslogUsage :: Maybe SyslogUsageOverride for Syslog usage
defaultOptions :: DaemonOptionsSource
Default values for the command line options.
type OptType = OptDescr (DaemonOptions -> Result DaemonOptions)Source
Abrreviation for the option type.
reqWithConversion :: (String -> Result a) -> (a -> DaemonOptions -> Result DaemonOptions) -> String -> ArgDescr (DaemonOptions -> Result DaemonOptions)Source
Helper function for required arguments which need to be converted as opposed to stored just as string.
Command line options
oShowHelp :: OptTypeSource
oShowVer :: OptTypeSource
oNoDaemonize :: OptTypeSource
oDebug :: OptTypeSource
oNoUserChecks :: OptTypeSource
oPort :: Int -> OptTypeSource
oBindAddress :: OptTypeSource
oSyslogUsage :: OptTypeSource
usageHelp :: String -> [OptType] -> StringSource
Usage info.
parseOptsSource
:: [String]The command line arguments
-> StringThe program name
-> [OptType]The supported command line options
-> IO (DaemonOptions, [String])The resulting options and leftover arguments
Command line parser, using the Options structure.
parseArgs :: String -> [OptType] -> IO (DaemonOptions, [String])Source
Small wrapper over getArgs and parseOpts.
Daemon-related functions
pidFileMode :: FileModeSource
PID file mode.
pidFileFlags :: OpenFileFlagsSource
PID file open flags.
_writePidFile :: FilePath -> IO FdSource
Writes a PID file and locks it.
formatIOError :: String -> IOError -> StringSource
Helper to format an IOError.
writePidFile :: FilePath -> IO (Result Fd)Source
Wrapper over _writePidFile that transforms IO exceptions into a Bad value.
setupDaemonEnv :: FilePath -> FileMode -> IO ()Source
Sets up a daemon's environment.
handleSigHup :: FilePath -> IO ()Source
Signal handler for reopening log files.
setupDaemonFDs :: Maybe FilePath -> IO ()Source
Sets up a daemon's standard file descriptors.
defaultBindAddrSource
:: IntThe port we want
-> FamilyThe cluster IP family
-> Result (Family, SockAddr)
Computes the default bind address for a given family.
resolveAddrHints :: Maybe AddrInfoSource
Default hints for the resolver
resolveAddr :: Int -> String -> IO (Result (Family, SockAddr))Source
Resolves a numeric address.
parseAddressSource
:: DaemonOptionsCommand line options
-> IntDefault port for this daemon
-> IO (Result (Family, SockAddr))
Based on the options, compute the socket address to use for the daemon.
daemonize :: FilePath -> IO () -> IO ()Source

Run an I/O action as a daemon.

WARNING: this only works in single-threaded mode (either using the single-threaded runtime, or using the multi-threaded one but with only one OS thread, i.e. -N1).

FIXME: this doesn't support error reporting and the prepfn functionality.

genericMain :: GanetiDaemon -> [OptType] -> (DaemonOptions -> IO ()) -> IO ()Source
Generic daemon startup.
innerMain :: GanetiDaemon -> DaemonOptions -> SyslogUsage -> IO () -> IO ()Source

Inner daemon function.

This is executed after daemonization.

Produced by Haddock version 2.6.0