| Copyright | (c) Romain Gérard 2014 David Fisher 2013 Lukas Epple 2019 |
|---|---|
| License | BSD3 |
| Maintainer | romain.gerard@erebe.eu |
| Stability | stable |
| Portability | Requires Systemd or will fail otherwise |
| Safe Haskell | Safe-Inferred |
| Language | Haskell2010 |
System.Systemd.Daemon.Fd
Description
This module implements all functions from System.Systemd.Daemon
that require or return Sockets purely using Fds.
This is especially useful if you have to do low level IO using
file descriptors or use a different socket library than network.
The API is exactly the same as System.Systemd.Daemon except that
Sockets have been replaced by Fds (actually
System.Systemd.Daemon uses this module internally). This also means
that System.Systemd.Daemon.Fd and System.Systemd.Daemon expose
conflicting functions. You either have to import System.Systemd.Daemon.Fd
qualified or like so:
import System.Systemd.Daemon hiding ( notifyWithFD, storeFd
, storeFdWithName
, getActivatedSockets
, getActivatedSocketsWithNames )
import System.Systemd.Daemon.Fd
The functions in System.Systemd.Daemon that are not implemented in this module are 100% compatible with System.Systemd.Daemon.Fd.
Notify functions
notifyWithFD :: Bool -> String -> Fd -> IO (Maybe ()) Source #
Same as notify, but send along a Fd.
Note that the caller must set the message, i. e. send FDSTORE=1
to actually store the file descriptor. In most cases it is probably best
to use storeFd or the notify-functions from System.Systemd.Daemon.
Equivalent to standard notifyWithFD.
storeFd :: Fd -> IO (Maybe ()) Source #
Notify Systemd to store a file descriptor for us. This together
with getActivatedSockets allows for zero downtime
restarts and socket activation.
Equivalent to standard storeFd
storeFdWithName :: Fd -> String -> IO (Maybe ()) Source #
Like storeFd, but associate the file descriptor with a name.
Best used along with getActivatedSocketsWithNames.
Equivalent to standard storeFdWithName
Socket activation functions
getActivatedSockets :: IO (Maybe [Fd]) Source #
Return Just a list of file descriptors if the current process
has been activated with one or more socket by systemd, Nothing
otherwise.
The file descriptors are in the same order as the sockets in the
associated .socket file. The sockets will have their family, type,
and status set according to the .socket file.
Equivalent to standard getActivatedSockets
getActivatedSocketsWithNames :: IO (Maybe [(Fd, String)]) Source #
Like getActivatedSockets, but also return the associated names.
If a file descriptor has no associated name, it will be a generic
one set by systemd.
Equivalent to standard getActivatedSocketsWithNames