mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-03 01:41:05 -05:00
Adding extra logging to celery tasks ans gunicorn, specifically log on SIGTERM and SIGINIT so that we can track better when an app restarts and why it restarts e.g. when it restarts after another signal.
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
from celery.signals import worker_process_shutdown
|
||||
from sqlalchemy.exc import SQLAlchemyError
|
||||
|
||||
from app import notify_celery
|
||||
@@ -23,6 +24,11 @@ def create_outcome_notification_statistic_tasks(notification):
|
||||
record_outcome_job_statistics.apply_async((str(notification.id),), queue=QueueNames.STATISTICS)
|
||||
|
||||
|
||||
@worker_process_shutdown.connect
|
||||
def worker_process_shutdown(sender, signal, pid, exitcode):
|
||||
current_app.logger.info('Statistics worker shutdown: PID: {} Exitcode: {}'.format(pid, exitcode))
|
||||
|
||||
|
||||
@notify_celery.task(bind=True, name='record_initial_job_statistics', max_retries=20, default_retry_delay=10)
|
||||
@statsd(namespace="tasks")
|
||||
def record_initial_job_statistics(self, notification_id):
|
||||
|
||||
Reference in New Issue
Block a user