Perform proper cleanup on termination of Haskell daemons
authorMichele Tartara <mtartara@google.com>
Wed, 18 Sep 2013 13:38:18 +0000 (15:38 +0200)
committerMichele Tartara <mtartara@google.com>
Wed, 18 Sep 2013 16:23:32 +0000 (18:23 +0200)
commit80adbbe1a8cb0b95927edefac5f502414ef7ed6c
tree79a246dae73921315934362ed2975d25f843ab22
parenta3de343e3ac17ac2ece2efb9ac437b3091586454
Perform proper cleanup on termination of Haskell daemons

Haskell deamons did not perform proper cleanup at termination. There was no code
for removing the pid file, and the code in LuxiD for removing the unix socket
file was not working, because it is implemented with a "finally" statement,
which is executed only when the main loop of the daemon is exited (either
normally, or through an exception), but not when it is terminated by a SIGTERM.

This commit adds a proper handler for SIGTERM, which transforms it into a
successful termination exception. This allows both the newly added cleanup code
for pid files and the unmodified cleanup code for unix sockets to be executed.

Fixes Issue 581 and 582.

Signed-off-by: Michele Tartara <mtartara@google.com>
Reviewed-by: Klaus Aehlig <aehlig@google.com>
src/Ganeti/Daemon.hs