Gracefull exit on sigTERM

Like the sigINT that was already handled, postgrest
should gracefuly shut down on a sigTERM. This is a
common way of stopping processes, used amongst
others by docker.

See: https://stackoverflow.com/questions/4042201/how-does-sigint-relate-to-the-other-termination-signals
This commit is contained in:
Remco Bloemen
2016-03-07 17:45:53 +01:00
parent ef021056c9
commit e5d420b2db
2 changed files with 6 additions and 4 deletions
+1
View File
@@ -6,6 +6,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
## Unreleased
### Fixed
- Terminate gracefully on SIGTERM - @recmo
## [0.3.1.0] - 2016-02-28
+5 -4
View File
@@ -60,10 +60,11 @@ main = do
#ifndef mingw32_HOST_OS
tid <- myThreadId
void $ installHandler keyboardSignal (Catch $ do
P.release pool
throwTo tid UserInterrupt
) Nothing
forM_ [sigINT, sigTERM] $ \sig ->
void $ installHandler sig (Catch $ do
P.release pool
throwTo tid UserInterrupt
) Nothing
#endif
result <- P.use pool $ do