This article assumes that you've already set up a Laravel application in Moss and that you're familiar with basic concepts about workers.

Set up your worker

Head to your Laravel website in Moss. Then click the 'Workers' tab and next click the 'Create worker' button.

Provide the following input:

  • The number of processes that must run simultaneously. Moss sets up Supervisor so that it guarantees that you're running as many processes as you provide here. Set as many processes as jobs you want to handle concurrently.
  • The command you need to run, e.g. php artisan queue:work . Look at the documentation of your version of Laravel to check the command you must run.

Click the 'Create' button and wait for Moss to finish the setup process. Now you may log into your server and check that you're worker is running:
ssh moss@<server-ip> 

moss@<server>:~$ sudo supervisorctl 
daemon-node-exporter:daemon-node-exporter_00 RUNNING pid 12741, uptime 0:03:57 RUNNING pid 12742, uptime 0:03:57
supervisor> exit

You can also check that there's a log file for the worker you've just set up:
ssh <site-user>@<server-ip> 

<site-user>@<server>:~$ ls /home/<site-user>/sites/<site-name>/logs/

If you need to remove any worker of your application at any moment, click the 'Delete' icon and Moss will configure your server accordingly.

Set up your deployment

Your worker is now up and running 💪. But when deploying a new version of your application, you'll likely want to restart your workers to make them use such version too, as the Laravel documentation describes.

To do this just head to the 'Deployments' tab for your website and edit the post-activation script to include the command php artisan queue:restart (or an equivalent one according to your Laravel version). Click the 'Update' button and your next deployment will restart the related workers 😊.

What's next?

Great! Now that workers aren't a big deal for you, you may add as many as you need.

Did this answer your question?