Properly Deploying Queues On Forge

Forge provisions web servers using the latest release of PHP 7.1, MySQL, and everything else you need to run robust Laravel applications in production. One additional feature of Forge is the ability to configure your queue workers using Supervisor. Supervisor will restart your queue workers if they exit unexpectedly.

Recently, we introduced support for configuring the number of processes a single Supervisor entry should create. This allows you to easily create a large number of workers without cluttering up your Forge interface with 25 worker entries:

When running queue workers as “daemons” by clicking the “Run Worker As Daemon” checkbox, you should always make sure your deployment script contains the php artisan queue:restart command. Daemon queue workers only boot the framework one time and then continue to process jobs using that same application instance. This means that if you update your code while a daemon queue worker is running, the worker will not receive the updated code until it is restarted:

The queue:restart command will stop all of the queue workers running on the machine and let Supervisor restart them, ensuring they are using the fresh code you just deployed.

If you are using Envoyer to deploy your code to Forge servers with zero-downtime, you can add a custom deployment hook to run the queue:restart Artisan command on all of your worker servers.

If you haven’t tried Forge yet, give it a shot!

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.