Question

How to setup Laravel queue for app

Hi,

I am looking for a way to get our Laravel queue working on the app platform. For this we’ve created a Redis DB and want to run the php artisan queue:work command to process the jobs.

For this I have a few questions.

  • Do we need to set the queue:work command as a Run Command in the app?
  • Can it be done in the Web Service App or does a Worker Component has any benefits for this?
  • How can the process be monitored and kept running. Do we still need to configure Supervise for it (as Laravel documentation suggests) and if so how can this be done in an app service?

Would be great to hear your suggestions and experiences with this.


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Kamal Nasser
DigitalOcean Employee
DigitalOcean Employee badge
October 27, 2020
Accepted Answer

Hi 👋🏼

The recommended way to do this is to run the queue runner as a worker component. You would set the run command to php artisan queue:work like you said.

Running it as a worker component removes the need for supervisor because then App Platform will manage it for you and ensure that it is always running, restarted on crashes, etc. You will also be able to see analytics for it separate from your actual Laravel app.

The other option is to run it alongside your Service component, but you will need to replace the run command with one that starts both the webserver (heroku-php-apache2 public/) and the queue runner (php artisan queue:work) at the same time and ensures that both are kept running and restarted if they were to crash.

That’s what supervisor does however it might be a little complicated to set up on App Platform as it is not available in the run environment so you will need to work around that as a non-root user in the run command. If you go this route I would recommend searching for a different process manager that is easier to run as non-root. I’m sure there’s a composer or npm CLI that does that out there.

So, in short, it’s much easier to run it as an App Platform Worker :)

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel