Log signal handling at notice

Signals feel like they belong with the other process-management info
we already log at notice -- more important than a simple info(), but
definitely not an error().

While we're at it, have Daemon include the receiving pid when logging
about SIGTERM.

Change-Id: I787b9d5a35ce760450bc7389b53f0540f70c8d76
This commit is contained in:
Tim Burke 2021-04-30 15:42:52 -07:00
parent b621a6f932
commit 05b2e894a9
3 changed files with 3 additions and 2 deletions

View File

@ -138,7 +138,7 @@ class DaemonStrategy(object):
def kill_children(*args):
self.running = False
self.logger.info('SIGTERM received')
self.logger.notice('SIGTERM received (%s)', os.getpid())
signal.signal(signal.SIGTERM, signal.SIG_IGN)
os.killpg(0, signal.SIGTERM)
os._exit(0)

View File

@ -1163,7 +1163,7 @@ def run_wsgi(conf_path, app_section, *args, **kwargs):
logger.error('Stopping with unexpected signal %r' %
running_context[1])
else:
logger.error('%s received (%s)', signame, os.getpid())
logger.notice('%s received (%s)', signame, os.getpid())
if running_context[1] == signal.SIGTERM:
os.killpg(0, signal.SIGTERM)
elif running_context[1] == signal.SIGUSR1:

View File

@ -139,6 +139,7 @@ class TestRunDaemon(unittest.TestCase):
with mock.patch('swift.common.daemon.os') as mock_os:
func()
self.assertEqual(mock_os.method_calls, [
mock.call.getpid(),
mock.call.killpg(0, signal.SIGTERM),
# hard exit because bare except handlers can trap SystemExit
mock.call._exit(0)