Skip to content

How to log when SIGTERM is received by a worker #2064

Closed Answered by karunpoudel-chr
karunpoudel-chr asked this question in Q&A
Discussion options

You must be logged in to vote

I think I found the solution:
Worker.handle_warm_shutdown_request() function logs info log.info('Warm shut down requested').

We can simply override it in child class:

class MyWorker(rq.Worker):
    def handle_warm_shutdown_request(self):
        logger.info("My custom handler")

worker = MyWorker('my-queue')
worker.work()

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by karunpoudel-chr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant