refactor: move interrupt out of releasePool helper

This commit is contained in:
Robert Vollmert
2022-08-02 09:24:14 +02:00
committed by Robert
parent ec23067e3e
commit eae169ca67
2 changed files with 6 additions and 3 deletions
+1 -1
View File
@@ -97,7 +97,7 @@ getPool :: AppState -> SQL.Pool
getPool = statePool
releasePool :: AppState -> IO ()
releasePool AppState{..} = SQL.release statePool >> throwTo stateMainThreadId UserInterrupt
releasePool AppState{..} = SQL.release statePool
getPgVersion :: AppState -> IO PgVersion
getPgVersion = readIORef . statePgVersion
+5 -2
View File
@@ -45,8 +45,11 @@ installSignalHandlers :: AppState.AppState -> IO ()
installSignalHandlers appState = do
-- Releases the connection pool whenever the program is terminated,
-- see https://github.com/PostgREST/postgrest/issues/268
install Signals.sigINT $ AppState.releasePool appState
install Signals.sigTERM $ AppState.releasePool appState
let interrupt = do
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
-- 'connectionWorker' exactly as before.