From: Vladimír Čunát Date: Thu, 10 Oct 2019 13:16:03 +0000 (+0200) Subject: modules/watchdog: use abort() for restarts X-Git-Tag: v4.3.0~14^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cc7ad97055c48b66929bc4c3c6372314faf8d72c;p=thirdparty%2Fknot-resolver.git modules/watchdog: use abort() for restarts Motivation: core-dump might be very useful, and in this case there are even very useful pointers on the C stack. --- diff --git a/modules/watchdog/README.rst b/modules/watchdog/README.rst index 04341e59c..cd2fbd038 100644 --- a/modules/watchdog/README.rst +++ b/modules/watchdog/README.rst @@ -17,8 +17,8 @@ answers correctly. To use this feature you must configure DNS name and type to q Each single query from watchdog must result in answer with RCODE = NOERROR or NXDOMAIN. Any other result will terminate the resolver -(with exit code 69) to allow the supervisor process to do cleanup and restart -the resolver. +(with SIGABRT) to allow the supervisor process to do cleanup, gather coredump +and restart the resolver. It is recommended to use a name with a very short TTL to make sure the watchdog is testing all parts of resolver and not only its cache. Obviously this check diff --git a/modules/watchdog/watchdog.lua b/modules/watchdog/watchdog.lua index 2251a4141..7a7f5aa54 100644 --- a/modules/watchdog/watchdog.lua +++ b/modules/watchdog/watchdog.lua @@ -3,6 +3,7 @@ local ffi = require('ffi') ffi.cdef([[ int sd_watchdog_enabled(int unset_environment, uint64_t *usec); int sd_notify(int unset_environment, const char *state); + void abort(void); ]]) local watchdog = {} @@ -13,8 +14,8 @@ local function sd_signal_ok() end function private.fail_callback() - log('[watchdog] TERMINATING resolver, supervisor is expected to restart it') - os.exit(69) -- unclean exit code = EX_UNAVAILABLE + log('[watchdog] ABORTING resolver, supervisor is expected to restart it') + ffi.C.abort() end -- logging diff --git a/systemd/kresd@.service.in b/systemd/kresd@.service.in index 3e30a33ed..6454cc2d1 100644 --- a/systemd/kresd@.service.in +++ b/systemd/kresd@.service.in @@ -14,7 +14,6 @@ ExecStart=@sbin_dir@/kresd --config=@etc_dir@/kresd.conf User=@user@ TimeoutStopSec=10s WatchdogSec=10s -RestartForceExitStatus=69 Restart=on-abnormal LimitNOFILE=1048576 Sockets=kresd.socket