fix: shutdown should wait for in flight requests
Upgraded warp to 3.4.13 which fixed https://github.com/yesodweb/wai/issues/853 Changed interrupt handling so that instead of killing the main thread, listening sockets are closed which triggers warp graceful shutdown.
This commit is contained in:
committed by
Steve Chavez
parent
3b1373ec02
commit
baebacf3db
@@ -22,6 +22,7 @@ import GHC.IO.Exception (IOErrorType (..))
|
||||
import System.IO.Error (ioeGetErrorType)
|
||||
|
||||
import Control.Monad.Except (liftEither)
|
||||
import Control.Monad.Extra (whenJust)
|
||||
import Data.Either.Combinators (mapLeft, whenLeft)
|
||||
import Data.Maybe (fromJust)
|
||||
import Data.String (IsString (..))
|
||||
@@ -79,8 +80,10 @@ run appState = do
|
||||
|
||||
AppState.schemaCacheLoader appState -- Loads the initial SchemaCache
|
||||
(mainSocket, adminSocket) <- initSockets conf
|
||||
|
||||
Unix.installSignalHandlers observer (AppState.getMainThreadId appState) (AppState.schemaCacheLoader appState) (AppState.readInDbConfig False appState)
|
||||
let closeSockets = do
|
||||
whenJust adminSocket NS.close
|
||||
NS.close mainSocket
|
||||
Unix.installSignalHandlers observer closeSockets (AppState.schemaCacheLoader appState) (AppState.readInDbConfig False appState)
|
||||
|
||||
Listener.runListener appState
|
||||
|
||||
|
||||
@@ -19,10 +19,9 @@ import System.Directory (removeFile)
|
||||
import System.IO.Error (isDoesNotExistError)
|
||||
|
||||
-- | Set signal handlers, only for systems with signals
|
||||
installSignalHandlers :: Observation.ObservationHandler -> ThreadId -> IO () -> IO () -> IO ()
|
||||
installSignalHandlers :: Observation.ObservationHandler -> IO () -> IO () -> IO () -> IO ()
|
||||
#ifndef mingw32_HOST_OS
|
||||
installSignalHandlers observer tid usr1 usr2 = do
|
||||
let interrupt = throwTo tid UserInterrupt
|
||||
installSignalHandlers observer interrupt usr1 usr2 = do
|
||||
install Signals.sigINT $ observer (Observation.TerminationUnixSignalObs "SIGINT") >> interrupt
|
||||
install Signals.sigTERM $ observer (Observation.TerminationUnixSignalObs "SIGTERM") >> interrupt
|
||||
install Signals.sigUSR1 usr1
|
||||
|
||||
Reference in New Issue
Block a user