mirror of
https://github.com/hibiken/asynq.git
synced 2026-04-25 23:15:51 +03:00
[GH-ISSUE #439] [FEATURE REQUEST] programmatically signal the server to shutdown #201
Labels
No labels
CLI
bug
designing
documentation
duplicate
enhancement
good first issue
good first issue
help wanted
idea
invalid
investigate
needs-more-info
performance
pr-welcome
pull-request
question
wontfix
work in progress
work in progress
work-around-available
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/asynq#201
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @ghstahl on GitHub (Apr 22, 2022).
Original GitHub issue: https://github.com/hibiken/asynq/issues/439
Originally assigned to: @hibiken on GitHub.
Is your feature request related to a problem? Please describe.
I am dynamically spinning up and shutting down servers based upon a config change.
i.e. my app can have many so-called asynq server, they are just go routines. In my test I have 2 running in a single app. I just can't get them to gracefully shutdown. I want the go routine they live in to end because
srv.Run()returned gracefully.I thought calling srv.Shutdown() would do it, but that is not how the code works.
asynq run
wait for signal
You can see that signal a shutdown is for everything, which isn't what I want. I just want to signal one of my running asynq servers to shutdown.
Describe the solution you'd like
Move the following from
waitForSignalsto the Server struct{} as a member variable.would now look like this.
add a new method to signal a shutdown.
Other Examples
@hibiken commented on GitHub (Apr 22, 2022):
@ghstahl thanks for creating an issue.
If you'd like to programmatically start and shutdown the server, then please use
Startinstead ofRun. (Run takes care of waiting for termination signal and callsShutdownon your behalf).You can see an example here: https://pkg.go.dev/github.com/hibiken/asynq#example-Server.Shutdown
@ghstahl commented on GitHub (Apr 23, 2022):
It's not a question of stopping and starting a server instance. I need to throw the whole thing away because it was configured to pull from a set of queues that are no longer valid.
As new configs come in, I can spin up new servers (hosted in a go routines) that have a set of queues never seen before.
Once a server instance is started, I can't shut it down, meaning I can't get rid of the go routine that hosted it.
As it stands, I would be left with dangling orphaned go routines that are hosting a server instance that is stopped (srv.Stop()) and shutdown (srv.Shutdown()), which I would like to not have.
The ask here is that I would like to surgically have a server instance stop running completely vs all of them being signaled to go away.
BTW: Would you say that the pull request I have in flight stands on its own as a feature that would be nice to have in the framework. i.e., signal a instance of a server to go away vs all of them.
@hibiken commented on GitHub (Apr 28, 2022):
@ghstahl Sorry for the late reply!
Are you calling
Server.Runto start a server in your goroutine? If so, please useServer.Startinstead.As long as you have reference to that server in your goroutine, you can shutdown the specific server by calling
Shutdownon the server.Example:
@ghstahl commented on GitHub (Apr 28, 2022):
Yes, one could say I am calling Server.Run 🤦♂️
Well, this is a relief, please excuse me while I go delete that fork of mine!