[GH-ISSUE #911] [QUESTION] How to handle shutdowns/restarts with systemctl #456

Closed
opened 2026-03-02 05:21:18 +03:00 by kerem · 1 comment
Owner

Originally created by @arjendevos on GitHub (Aug 28, 2024).
Original GitHub issue: https://github.com/hibiken/asynq/issues/911

In production we compile to a single go binary and run it through systemctl. However restarts/stop don't work as they hang forever. I know we have to use kill -TERM etc but we don't know the in our CI?

Is there any docs or examples for an use-case like this?

EDIT:
I now have this:

# Graceful stop
ExecStop=/bin/kill -TSTP $MAINPID
ExecStop=/bin/sleep 10
ExecStop=/bin/kill -TERM $MAINPID

I get these logs:

INFO: Stopping processor
INFO: Processor stopped
INFO: Starting graceful shutdown
INFO: Waiting for all workers to finish...
INFO: All workers have finished
INFO: Exiting

However it seems to hang on Exiting and it never completes?

Originally created by @arjendevos on GitHub (Aug 28, 2024). Original GitHub issue: https://github.com/hibiken/asynq/issues/911 In production we compile to a single go binary and run it through systemctl. However restarts/stop don't work as they hang forever. I know we have to use kill -TERM <pid> etc but we don't know the <pid> in our CI? Is there any docs or examples for an use-case like this? EDIT: I now have this: ```bash # Graceful stop ExecStop=/bin/kill -TSTP $MAINPID ExecStop=/bin/sleep 10 ExecStop=/bin/kill -TERM $MAINPID ``` I get these logs: ```bash INFO: Stopping processor INFO: Processor stopped INFO: Starting graceful shutdown INFO: Waiting for all workers to finish... INFO: All workers have finished INFO: Exiting ``` However it seems to hang on Exiting and it never completes?
kerem closed this issue 2026-03-02 05:21:18 +03:00
Author
Owner

@arjendevos commented on GitHub (Aug 28, 2024):

Oke found the issue, I was running it in a goroutine. Makes sense now I think about it. Changing it to the main thread fixed everything.

<!-- gh-comment-id:2315507476 --> @arjendevos commented on GitHub (Aug 28, 2024): Oke found the issue, I was running it in a goroutine. Makes sense now I think about it. Changing it to the main thread fixed everything.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/asynq#456
No description provided.