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

gitwithravish's avatar

How to stop laravel scheduler gracefully during new deployment ?

I have 2 types of scheduled commands.

  • Short Job - Runs every 30 seconds (and takes 10 seconds to be completed)
  • Long Job - Runs Every hour (and takes 45 minutes to be completed)

I have configured CI\CD pipelines in different environments (AWS EC2, AWS Elastic Beanstalks, Azure Kubernetes, CPanel etc.) I have noticed various weird behaviours while deployment. Followings are some examples

  • Deployment got stuck because a long running job was executing.
  • Deployment successful but the running job execution broke and the scheduler started from next job after new deployment

What is the appropriate way to design the CI/CD so that the scheduler execution is not affected unexpectedly ?

0 likes
3 replies
christian-qode's avatar

How are you running your scheduled commands?

We're using Supervisor and stop all queue workers when the deployment start, rereads en start again when deployment is done.

Although not tested with very long jobs, I think the jobs will be killed when supervisor stops. Of course you have to run them again if needed when the deployment is finished (or wait until the next cycle of acceptable).

gitwithravish's avatar

@christian-qode currently i am deploying kubernetes and i have flexibility to configure the workers in any way possible.

How did u stop all queue workers ?

christian-qode's avatar

@gitwithravish We run this set of commands:

    supervisorctl stop laravel-default-worker:* laravel-mail-worker:*
    supervisorctl reread
    supervisorctl update
    supervisorctl start laravel-default-worker:* laravel-mail-worker:*

This is done by Laravel Envoy but of course this can be implemented in different types of deployment as well.

1 like

Please or to participate in this conversation.