Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

stevemoretz's avatar

What happens to running jobs on server shutdown

Hello, this is my first question here and I hope it doesn't sound stupid, I'm using supervisord to run the jobs, I've read somewhere that if you stop the process from supervisord it send a kill signal to all the jobs and then they will handle their business before getting shut down (the states of the job goes to failed? I'd suppose)

Now my second question is that does the same thing happen, if a server shutdown occurs? Either a manual shutdown via the ssh, or when a data center's downtime issue occurs?

It's kind of important for my application, that the job's states get handled.

Thank you so much for reading this.

0 likes
2 replies
Snapey's avatar
Snapey
Best Answer
Level 122

it's important to distinguish between worker and job

when supervisor asks the workers to stop they will complete the current job then not start a new one ( that's my understanding) and then shutdown. If they can complete the job gracefully probably depends how long your jobs take to run and if related dependent services go down before they finish, eg mysql on the same server may be told to shutdown at the same time so the state of the job will be indeterminate

This is why there are things like redundant power and planned outages

Best way to protect your app is to shut it down first. As you cannot always guarantee this you should think about detecting incomplete activity

1 like
stevemoretz's avatar

@Snapey @Snapey thank you for your detailed answer, it makes a lot of sense.

My jobs are pretty long so I guess I should ask another question in that matter.

Please or to participate in this conversation.