Skip to content

Commit

Permalink
drop stack trace to the log on SIGUSR1
Browse files Browse the repository at this point in the history
  • Loading branch information
sibiryakov committed Jun 29, 2016
1 parent fc78c07 commit cd31bdf
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
7 changes: 7 additions & 0 deletions frontera/worker/db.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# -*- coding: utf-8 -*-
import logging
from traceback import format_stack
from signal import signal, SIGUSR1
from logging.config import fileConfig
from argparse import ArgumentParser
from time import asctime
Expand Down Expand Up @@ -99,8 +101,13 @@ def set_process_info(self, process_info):
self.process_info = process_info

def run(self):
def debug(sig, frame):
logger.critical("Signal received: printing stack trace")
logger.critical(str("").join(format_stack(frame)))

self.slot.schedule(on_start=True)
self._logging_task.start(30)
signal(SIGUSR1, debug)
reactor.addSystemEventTrigger('before', 'shutdown', self.stop)
reactor.run()

Expand Down
8 changes: 8 additions & 0 deletions frontera/worker/strategy.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# -*- coding: utf-8 -*-
from time import asctime
import logging
from traceback import format_stack
from signal import signal, SIGUSR1
from logging.config import fileConfig
from argparse import ArgumentParser
from os.path import exists
Expand Down Expand Up @@ -202,8 +204,14 @@ def run(self):
def errback(failure):
logger.exception(failure.value)
self.task.start(interval=0).addErrback(errback)

def debug(sig, frame):
logger.critical("Signal received: printing stack trace")
logger.critical(str("").join(format_stack(frame)))

self.task.start(interval=0).addErrback(errback)
self._logging_task.start(interval=30)
signal(SIGUSR1, debug)
reactor.addSystemEventTrigger('before', 'shutdown', self.stop)
reactor.run()

Expand Down

0 comments on commit cd31bdf

Please sign in to comment.