Using rdev

Processes and scheduled tasks

Some parts of an app run outside web requests: queue workers, Horizon, a Reverb websocket server, Laravel's scheduler. rdev runs them for you on the server, keeps them running and shows how they are doing on your server's page in the panel. This needs rdev 0.2.0-beta.24 or later on the server.

Processes

A process is a command that should always be running, such as php artisan queue:work. rdev starts it in the project folder, starts it again if it stops, and can run several copies.

In the panel, open the server from Servers in the sidebar and choose Add process in the Processes card. Pick a kind:

  • Queue worker: php artisan queue:work --tries=3;
  • Horizon: php artisan horizon (the row's menu opens the Horizon dashboard);
  • Reverb: php artisan reverb:start;
  • Custom: any command, for any language.

Then choose the project and how many copies to run. The table shows each process and whether all of its copies are running. The ⋯ menu on a row starts, stops or restarts it, opens Settings to change its command or number of copies, or removes it. A process you stop stays stopped until you start it again.

On the server:

Command What it does
rdev process add shop queue --command "php artisan queue:work" --count 2 Adds a process with two copies
rdev process list Lists processes and how many copies run
rdev process stop shop queue / start / restart Stops, starts or restarts every copy
rdev process edit shop queue --count 4 Changes the command or the number of copies
rdev process logs shop queue Shows the last lines of each copy's output
rdev process remove shop queue Stops and removes it

After you deploy new code, restart queue workers and Horizon so they load it: rdev process restart shop queue.

Scheduled tasks

A scheduled task runs a command at set times, like cron. Times are in UTC, the server's clock. A run never starts while the previous run of the same task is still going.

In the Scheduled tasks card, choose Add scheduled task. Laravel scheduler adds php artisan schedule:run every minute, which is all a Laravel app needs: the schedule itself stays in your code. Custom takes any command and schedule.

A schedule has five fields: minute, hour, day of the month, month and day of the week. For example:

Schedule Runs
* * * * * Every minute
*/15 * * * * Every 15 minutes
0 3 * * * Every day at 03:00 UTC
30 8 * * 1-5 Weekdays at 08:30 UTC
@hourly, @daily, @weekly At the start of every hour, day or week

The table shows when each task last ran, whether it succeeded and how long it took, and when it runs next. Click the result to see its output. The switch turns a task off without removing it; it then runs only when you choose Run now.

On the server:

Command What it does
rdev cron add shop scheduler --schedule "* * * * *" --command "php artisan schedule:run" Adds Laravel's scheduler
rdev cron list Lists the tasks
rdev cron run shop scheduler Runs it now
rdev cron disable shop scheduler / enable Turns it off or on
rdev cron logs shop scheduler Shows the last run's output
rdev cron remove shop scheduler Removes it