Graceful shutdown of gearman job server

Skip to first unread message

Adam Mills

Jan 20, 2020, 10:51:45 AM1/20/20
to Gearman
I saw that the shutdown command was removed from the client protocol

Is there any alternative way to trigger a graceful shutdown of a gearman job server? It doesn't have to come from a client, a command on the job server itself would work as well.

My use case is I'm trying to set up a graceful handoff from a primary gearman job server, to a secondary server to perform server maintenance. My plan is to register both servers with clients and workers, and gracefully shutdown the primary server, so that the secondary server can accept requests while the primary job server is down.

Edward J. Sabol

Jan 21, 2020, 11:36:41 AM1/21/20
Well, if you really need that functionality, you could always fork the GitHub project and re-integrate the code that was removed in that PR. Just make sure you have strict network controls as to prevent unauthorized network access to your gearmand server.

If you don't want to fork the code, then I suppose you could add a task to your workers which forks a child who sleeps for a couple of seconds and then kills the gearmand server. The parent of the child would immediately return JOB_SUCCESS so that the client isn't left hanging. That's how I would try to do it anyway.

Hope this helps,

Adam Mills

Jan 22, 2020, 10:21:25 AM1/22/20
to Gearman
OK, for posterity I did some digging into the source, and I actually found that sending a SIGUSR1 kill to the gearmand process will trigger a graceful shutdown. That will work for what I need! I can't find this behavior documented anywhere though.
Reply all
Reply to author
0 new messages