asynq
asynq copied to clipboard
Question: Individual ServerInfo and identifying current server via UUID
I have another question on graceful shutdown that I think is related to this; The server has a Stop() and a Shutdown(), from reading the comments Stop() prevents the server from picking up more tasks and Shutdown() well .. shutsdown. In theory one can call Stop() on a server, then wait until that server has finished processing all it's tasks, then call Shutdown().
Looking at the inspector I can see a Servers() call which returns all servers, and serverinfos include an ID. But I can't see how I can get the ID of the server I called Stop() on ..?
So in practice, I'm unclear how I would check that the server I've just called Stop() on is actually ready for Shutdown(). I mean, sure I could set some kind of max task time and wait that long before shutdown .. but that seems a little weird.
I'd like to request:
- calling NewServer should yield a way to get a server ID
- ideally, we'd have a way to GetServerInfo(serverID string) .. Happy to add myself if you want.
My apologies if there is a way to do this currently and I haven't found it!
Originally posted by @voidshard in https://github.com/hibiken/asynq/issues/710#issuecomment-1762784681
In theory one can call Stop() on a server, then wait until that server has finished processing all it's tasks, then call Shutdown().
Yeah. But calling shutdown is enough as it will call processor.stop() internally (same as Stop()).
But I can't see how I can get the ID of the server I called Stop() on
Hmm. seems correct, the heartbeater doesn't log this info.
calling NewServer should yield a way to get a server ID
Would a debug log line be enough?
ideally, we'd have a way to GetServerInfo(serverID string)
At the inspector level? It could be possible.
Yeah. But calling shutdown is enough as it will call processor.stop() internally (same as Stop()).
In local testing Stop() doesn't seem to block though (apologies if I'm wrong here, I can check the code when I have time) -- if Stop() does block until it's finished processing everything it has then that's ok.
Would a debug log line be enough?
At the inspector level? It could be possible.
My idea here was that I could have something in my code that checks that the server has finished processing before allowing it to be killed -- so I'd want a way to get the ID in code that wraps the server.