Ployter

Processes, scheduled jobs and commands

How to run queues and workers alongside the application, schedule jobs with cron and run one-off commands with the live image.

Besides the main process, which serves the domain, a service can run other commands with the same image and the same variables: processes that stay up all the time (queues, workers), scheduled jobs (cron) and one-off commands (migrations, maintenance scripts).

These tabs show up on application services. A database in a container has no Processes or Commands & cron tab.

Extra processes

An extra process is one more container, with the same image and variables as the application, but with a different command and no domain. Use it for queues, workers and schedulers.

Add a process

  1. Open the service and go to the Processes tab.
  2. Click Add process, or one of the suggestions for the detected framework.
  3. Fill in:
    • Name: lowercase letters, numbers and hyphens (e.g. worker). It goes into the container name.
    • Command: runs with /bin/sh -c, in place of the application's start command. It must keep running; it can't exit.
    • Instances: how many copies of the process (from 1 to 20).
    • CPU and Memory: optional limits.
  4. Click Save.
  5. Run a deploy. Processes start from the next deploy.

Processes tab of the api service with the worker process running
Processes tab of the api service with the worker process running

Suggestions the panel offers, by framework:

Framework Processes
Laravel queue (php artisan queue:work), scheduler (php artisan schedule:work), horizon
Symfony messenger
Django celery, beat
Flask, FastAPI celery
Rails sidekiq
AdonisJS queue

For a Node app, write your worker's command, for example node dist/worker.js.

How processes follow the deploy

  • On each deploy, the processes start with the new version and only switch versions once they are up. It is the equivalent of "restarting the queues".
  • If a process crashes right after starting, the deploy is cancelled and the previous version stays.
  • The On the server column shows the real state: running, restart loop or not running.
  • A removed process keeps running until the next deploy.

Each process's menu has View logs and Open terminal, which open the Logs and Terminal tabs already on that process.

Note

With replicas, extra processes run only on the primary server.

Run a one-off command

The Commands & cron tab runs a command once, in a new container with the live version's image, the current variables and the project network. The command sees the database just like the application does, and it doesn't touch the container serving the site.

  1. Open the service and go to the Commands & cron tab.
  2. Under Run command, type the command (e.g. npx prisma migrate status).
  3. Choose the Max time: up to 1 min, 5 min, 30 min or 2 h.
  4. Click Run.

The output shows live. To stop it, click Stop. Variable values show as *** in the output.

The service needs a live version. Without a deploy, there's no image to run.

Tip

From the CLI: ployter run "php artisan migrate --force". See CLI.

Scheduled jobs

A scheduled job is a cron in the panel: at each scheduled time, the command runs in a new container, just like Run command. If the previous run hasn't finished yet, that time is skipped.

Create a job

  1. In the Commands & cron tab, under Scheduled jobs, click New job.
  2. Fill in:
    • Name: e.g. Clean carts.
    • Command: e.g. node dist/jobs/clean-carts.js.
    • When it runs: pick the frequency (Every X minutes, Every X hours, Every day, Weekdays, Once a week, Once a month) and fill in the time. If you know cron, use Custom (cron), with the five fields.
    • Time zone: the expression's times follow this time zone. The default is America/Sao_Paulo.
    • Max time: from 1 min to 24 h.
    • Active: uncheck it to create the job paused.
  3. Click Save.

Below the time, the form shows how it reads in plain language and the cron expression. In Custom (cron), the five fields are minute, hour, day, month and day of the week:

*/15 * * * *    every 15 minutes
0 3 * * *       every day at 03:00
30 8 * * 1      every Monday at 08:30
0 0 1 * *       the 1st of every month, at midnight

New scheduled job modal set to Every day at 03:00
New scheduled job modal set to Every day at 03:00

Each job's menu has: Run now, View runs, Pause (or Resume), Edit and Remove.

Tip

In Laravel, a * * * * * job with php artisan schedule:run covers the whole scheduler. Another option is the scheduler process in Processes.

Run history

The Runs card lists one-off commands and job runs, with status, duration and who triggered them. Filter by All, One-off commands only or by job. Click a row to see the full output, the server, the start time, the duration and the exit code.

The statuses: Queued, Running, Succeeded, Failed and Timed out.

The history keeps 14 days.

Permissions

  • Run commands and scheduled jobs lets you run commands and create, edit and pause jobs.
  • View logs lets you see the history and the output of runs.
  • Edit service configuration lets you change extra processes.

See Teams, members and roles.