wai-graceful-0.1.0.1: Graceful shutdown for WAI applications.

Safe HaskellNone

Network.Wai.Graceful

Description

 app req = do
     liftIO $ somethingImportant -- like threadDelay 100000000
     LBSResponse status200 [("Content-Type", "text/plain")] "Finished!"

 main = do
     gs <- initGraceful

     forkIO $ run 8000 (graceful gs app)

     waitForTermination >> gracefulShutdown 15 gs
     putStrLn "Bye!"

Synopsis

Documentation

graceful :: Graceful -> Application -> ApplicationSource

WAI Middleware that keeps track of active connections and blocks further requests with HTTP503.

gracefulShutdownSource

Arguments

:: Int

Timeout in seconds.

-> Graceful 
-> IO () 

Trigger shutdown and monitor progress.

waitForTermination :: IO ()Source

Wait for TERM signal.