Workers 101

Basic concepts about site workers

Basic concepts

Sometimes your application requires some processes (workers) to run in the background awaiting for a job to be done. Usually your workers read from a message queue to perform a particular task, e.g. to send emails, resize images, and the like.

Moss installs and configures Supervisor in your servers to make sure that your applications’ workers keep running in the background. From Moss you may create as many workers as your websites require. You just have to provide Moss with the command to be run and the number of processes that must be simultaneously active. Moss will set up your worker in Supervisor on your behalf.

In addition to check out the workers of each website from Moss, you may log into your server and check their state at any moment:
ssh moss@<server-ip> 

moss@<server>:~$ sudo supervisorctldaemon-node-exporter:daemon-node-exporter_00 RUNNING pid 14815, uptime 1:01:55supervisor> exit

The server of the former example isn’t running any worker yet. However, it runs a daemon to collect server metrics. Don’t stop such daemon manually or Moss won’t be able to query the state of your services or monitor your server.

Logs from each worker are stored in a file within the directory of your web application: /home/<site-user>/sites/<site-name>/logs/workers/ . In case you don’t need a given worker any more, you may remove it from your server using Moss.

Use cases

Now we’ve seen some basic concepts about workers, it’s time to focus on a specific example: