@@ -70,12 +70,14 @@ module Network.Wai.Handler.Warp (
70 , setSlowlorisSize
70 , setSlowlorisSize
71 , setHTTP2Disabled
71 , setHTTP2Disabled
72 , setLogger
72 , setLogger
73+ , setGracefulShutdownTimeout
73 -- ** Getters
74 -- ** Getters
76 , getOnOpen
77 , getOnOpen
77 , getOnClose
78 , getOnClose
78 , getOnException
79 , getOnException
80+ , getGracefulShutdownTimeout
79 -- ** Exception handler
81 -- ** Exception handler
80 , defaultOnException
82 , defaultOnException
81 , defaultShouldDisplayException
83 , defaultShouldDisplayException
@@ -244,6 +246,10 @@ getOnClose = settingsOnClose
244getOnException :: Settings -> Maybe Request -> SomeException -> IO ()
246getOnException :: Settings -> Maybe Request -> SomeException -> IO ()
245getOnException = settingsOnException
247getOnException = settingsOnException
249+-- | Get the graceful shutdown timeout
250+getGracefulShutdownTimeout :: Settings -> Maybe Int
251+getGracefulShutdownTimeout = settingsGracefulShutdownTimeout
247-- | A code to install shutdown handler.
253-- | A code to install shutdown handler.
249-- For instance, this code should set up a UNIX signal
255-- For instance, this code should set up a UNIX signal
@@ -347,6 +353,13 @@ setLogger :: (Request -> H.Status -> Maybe Integer -> IO ())
347 -> Settings -> Settings
353 -> Settings -> Settings
348setLogger lgr y = y { settingsLogger = lgr }
354setLogger lgr y = y { settingsLogger = lgr }
356+-- | Set the graceful shutdown timeout. A timeout of `Nothing' will
357+-- wait indefinitely, and a number, if provided, will be treated as seconds
358+-- to wait for requests to finish, before shutting down the server entirely.
359+setGracefulShutdownTimeout :: Maybe Int
360+ -> Settings -> Settings
361+setGracefulShutdownTimeout time y = y { settingsGracefulShutdownTimeout = time }
350-- | Explicitly pause the slowloris timeout.
363-- | Explicitly pause the slowloris timeout.
352-- This is useful for cases where you partially consume a request body. For
365-- This is useful for cases where you partially consume a request body. For