From f02c74cce09ca52e517d96587f99c849b48ac636 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Wed, 28 Oct 2015 10:16:39 -0400 Subject: [PATCH] Add facility to dump trace to log If confluent gets stuck, provide a debug facility to sample where it is stuck. Sending confluent SIGUSR1 will now cause /var/log/confluent/hangtraces to get written to. --- confluent_server/confluent/main.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/confluent_server/confluent/main.py b/confluent_server/confluent/main.py index 0d867db2..07b54955 100644 --- a/confluent_server/confluent/main.py +++ b/confluent_server/confluent/main.py @@ -50,6 +50,8 @@ except ImportError: import sys import os import signal +import time +import traceback def _daemonize(): @@ -119,6 +121,11 @@ def _checkpidfile(): def terminate(signalname, frame): sys.exit(0) +def dumptrace(signalname, frame): + ht = open('/var/log/confluent/hangtraces', 'a') + ht.write('Dumping active trace on ' + time.strftime('%X %x\n')) + ht.write(''.join(traceback.format_stack(frame))) + ht.close() def doexit(): if not havefcntl: @@ -138,6 +145,7 @@ def _initsecurity(config): def run(): + signal.signal(signal.SIGUSR1, dumptrace) if havefcntl: _checkpidfile() conf.init_config()