refactor: move interrupt out of releasePool helper
This commit is contained in:
@@ -97,7 +97,7 @@ getPool :: AppState -> SQL.Pool
|
|||||||
getPool = statePool
|
getPool = statePool
|
||||||
|
|
||||||
releasePool :: AppState -> IO ()
|
releasePool :: AppState -> IO ()
|
||||||
releasePool AppState{..} = SQL.release statePool >> throwTo stateMainThreadId UserInterrupt
|
releasePool AppState{..} = SQL.release statePool
|
||||||
|
|
||||||
getPgVersion :: AppState -> IO PgVersion
|
getPgVersion :: AppState -> IO PgVersion
|
||||||
getPgVersion = readIORef . statePgVersion
|
getPgVersion = readIORef . statePgVersion
|
||||||
|
|||||||
@@ -45,8 +45,11 @@ installSignalHandlers :: AppState.AppState -> IO ()
|
|||||||
installSignalHandlers appState = do
|
installSignalHandlers appState = do
|
||||||
-- Releases the connection pool whenever the program is terminated,
|
-- Releases the connection pool whenever the program is terminated,
|
||||||
-- see https://github.com/PostgREST/postgrest/issues/268
|
-- see https://github.com/PostgREST/postgrest/issues/268
|
||||||
install Signals.sigINT $ AppState.releasePool appState
|
let interrupt = do
|
||||||
install Signals.sigTERM $ AppState.releasePool appState
|
AppState.releasePool appState
|
||||||
|
throwTo (AppState.getMainThreadId appState) UserInterrupt
|
||||||
|
install Signals.sigINT interrupt
|
||||||
|
install Signals.sigTERM interrupt
|
||||||
|
|
||||||
-- The SIGUSR1 signal updates the internal 'DbStructure' by running
|
-- The SIGUSR1 signal updates the internal 'DbStructure' by running
|
||||||
-- 'connectionWorker' exactly as before.
|
-- 'connectionWorker' exactly as before.
|
||||||
|
|||||||
Reference in New Issue
Block a user