warp-systemd-0.2.0.0: Socket activation and other systemd integration for the Warp web server (WAI)
Safe HaskellNone
LanguageHaskell2010

Network.Wai.Handler.Warp.Systemd

Description

This modules provides function that help start the Warp web server using systemd's socket activation feature.

Synopsis

Documentation

runSystemdWarp Source #

Arguments

:: 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

logWarn :: Lens' SystemdSettings (String -> IO ()) Source #

How to log an info message.

Default: hPutStrLn stderr . ("WARNING: " ++)

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 ()

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 ()'

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