[GH-ISSUE #768] Question: Individual ServerInfo and identifying current server via UUID #373

Open
opened 2026-03-02 05:20:46 +03:00 by kerem · 2 comments
Owner

Originally created by @kamikazechaser on GitHub (Oct 19, 2023).
Original GitHub issue: https://github.com/hibiken/asynq/issues/768

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

Originally created by @kamikazechaser on GitHub (Oct 19, 2023). Original GitHub issue: https://github.com/hibiken/asynq/issues/768 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_
Author
Owner

@kamikazechaser commented on GitHub (Oct 19, 2023):

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.

<!-- gh-comment-id:1770690880 --> @kamikazechaser commented on GitHub (Oct 19, 2023): > 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.
Author
Owner

@voidshard commented on GitHub (Oct 20, 2023):

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.

<!-- gh-comment-id:1772360998 --> @voidshard commented on GitHub (Oct 20, 2023): `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.
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#373
No description provided.