Safe Haskell | None |
---|---|
Language | Haskell2010 |
This modules provides function that help start the Warp web server using systemd's socket activation feature.
Synopsis
- runSystemdWarp :: SystemdSettings -> Settings -> Application -> IO ()
- data SystemdSettings
- defaultSystemdSettings :: SystemdSettings
- logInfo :: Lens' SystemdSettings (String -> IO ())
- setLogInfo :: (String -> IO ()) -> SystemdSettings -> SystemdSettings
- logWarn :: Lens' SystemdSettings (String -> IO ())
- setLogWarn :: (String -> IO ()) -> SystemdSettings -> SystemdSettings
- requireSocketActivation :: Lens' SystemdSettings Bool
- setRequireSocketActivation :: Bool -> SystemdSettings -> SystemdSettings
- heartbeatInterval :: Lens' SystemdSettings (Maybe Int)
- setHeartbeatInterval :: Maybe Int -> SystemdSettings -> SystemdSettings
- heartbeatCheck :: Lens' SystemdSettings (IO ())
- setHeartbeatCheck :: IO () -> SystemdSettings -> SystemdSettings
- onBeginShutdown :: Lens' SystemdSettings (IO ())
- setOnBeginShutdown :: IO () -> SystemdSettings -> SystemdSettings
- dontOverrideInstallShutdownHandler :: Lens' SystemdSettings Bool
- setDontOverrideInstallShutdownHandler :: Bool -> SystemdSettings -> SystemdSettings
- data SocketActivationException = SocketActivationException String
Documentation
:: SystemdSettings | |
-> Settings | Web server settings |
-> Application | Web application |
-> IO () |
Run a web application, see SystemdSettings
for details.
Note that Warp itself has some Settings
settings related to
the server process lifecycle, such as
setInstallShutdownHandler
. However, you do not have to
include a ready notification using setBeforeMainloop
, because
runSystemdWarp
does this for you.
Settings
data SystemdSettings Source #
Warp-systemd integration settings. See the lenses in this module for details.
Note that Warp itself has some settings related to the server process lifecycle, for example setInstallShutdownHandler
.
defaultSystemdSettings :: SystemdSettings Source #
Default settings. See the lenses in this module for details.
logInfo :: Lens' SystemdSettings (String -> IO ()) Source #
How to log an info message.
Default: hPutStrLn stderr
setLogInfo :: (String -> IO ()) -> SystemdSettings -> SystemdSettings Source #
See logInfo
logWarn :: Lens' SystemdSettings (String -> IO ()) Source #
How to log an info message.
Default: hPutStrLn stderr . ("WARNING: " ++)
setLogWarn :: (String -> IO ()) -> SystemdSettings -> SystemdSettings Source #
See logWarn
requireSocketActivation :: Lens' SystemdSettings Bool Source #
If True, runSystemdWarp
throw a SocketActivationException
if
the server is started without socket activation.
Default: False (continue)
heartbeatInterval :: Lens' SystemdSettings (Maybe Int) Source #
If Just n
, runSystemdWarp
emits a heartbeat notification to
systemd every n
seconds.
Default: Nothing
heartbeatCheck :: Lens' SystemdSettings (IO ()) Source #
Run an action before emitting a hearbeat and if it throws an exception, print a warning and skip systemd notification.
Default: return ()
setHeartbeatCheck :: IO () -> SystemdSettings -> SystemdSettings Source #
See heartbeatCheck
onBeginShutdown :: Lens' SystemdSettings (IO ()) Source #
Action to run on shutdown. This will be called when a shutdown signal has been received from systemd and the listening socket has been closed. This means that no new incoming requests will be received, but previous requests are still being processed.
Control flow should return to the caller of runSystemdWarp
when
all requests have been handled.
Default: 'return ()'
setOnBeginShutdown :: IO () -> SystemdSettings -> SystemdSettings Source #
See onBeginShutdown
Low-level Settings
dontOverrideInstallShutdownHandler :: Lens' SystemdSettings Bool Source #
If True
, do not override Settings'
with
setInstallShutdownHandler
. This lets you provide your own
shutdown handler functionality. Enabling this setting will
cause the default installShutdownHandler
to not be set,
with the effect of preventing the onBeginShutdown
action and
preventing the systemd ‘stopping’ notification.
Default: Nothing
Exceptions
data SocketActivationException Source #
These only occur during startup.