refactor: move pool release on shutdown out of signal handler
This changes behaviour somewhat in that: - We now consistently release the pool on shutdown, even on non-Unix platforms, and including for CmdDumpConfig. - We release the pool *after* interrupting `App.run`, which will rather cause more than fewer connection to be closed properly. (Previously any in-use connections would not have been caught by `releasePool`, though *maybe* the `UserInterrupt` handling in the web handler ends up closing the connections properly already anyway). (The main aim of the change is to make it clearer when and why the pool is released.)
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
module PostgREST.AppState
|
||||
( AppState
|
||||
, destroy
|
||||
, getConfig
|
||||
, getDbStructure
|
||||
, getIsListenerOn
|
||||
@@ -89,6 +90,9 @@ initWithPool newPool conf =
|
||||
<*> myThreadId
|
||||
<*> newIORef 0
|
||||
|
||||
destroy :: AppState -> IO ()
|
||||
destroy = releasePool
|
||||
|
||||
initPool :: AppConfig -> IO SQL.Pool
|
||||
initPool AppConfig{..} =
|
||||
SQL.acquire (configDbPoolSize, configDbPoolTimeout, toUtf8 configDbUri)
|
||||
|
||||
Reference in New Issue
Block a user