Matomo Analytics

Documentation

How do I set up a queue worker?

Queue workers process your application's queued jobs in the background. Ploi runs them under Supervisor, so they start automatically and restart if th...

Queue workers process your application's queued jobs in the background. Ploi runs them under Supervisor, so they start automatically and restart if they crash or the server reboots.

Creating a queue worker

Open your site and go to the Queue section, then add a worker. The most important settings are:

  • Connection — the queue connection to process (for example redis or database), matching your app's config/queue.php.
  • Queue — the queue name(s) to work, e.g. default.
  • Processes — how many worker processes to run in parallel (1–100).
  • Timeout, sleep, tries, backoff, memory — these map directly to the queue:work options, so you can tune how long a job may run, how long to wait when the queue is empty, retry counts and the memory limit.

Behind the scenes Ploi runs php artisan queue:work with your chosen options as the site's user, and writes each worker's output to a per-worker log you can view in the panel.

Restarting workers after a deploy

Workers keep the old code in memory, so after deploying new code you should restart them. Add this to the end of your deploy script:

php8.5 /home/ploi/example.com/artisan queue:restart

You can also restart, pause, edit or delete a worker from the Queue section at any time.

Running a custom background process

If you need a long-running process that isn't a Laravel queue worker (for example a Node.js service), use the Daemons section on the server instead, where you can supply any command, the number of processes, the system user and a working directory.

Dennis Smink

Written by Dennis Smink

Dennis brings over 13 years of hands-on experience in server management, specializing in optimizing web services for scalability and security.

Ready to dive in?
Start your free trial today.

Create an account and enjoy your 5-day free trial — no credit card required.

Start your free trial