Keep long-running processes alive with daemons

llms.txt

Some programs are meant to run all the time: a Laravel queue worker, a WebSocket server, a custom script that listens for messages. If you start one in an SSH session, it dies when the session ends. A daemon in SrvYard is the same command run by Supervisor, a small process manager that starts it when the server boots, restarts it if it crashes, and can run several copies side by side.

This article creates a queue worker daemon, explains every field in the form and shows how to control and inspect daemons afterwards. For work that should run on a timer rather than all the time, see Scheduled commands on a server.

Before you begin

  • A ready server with Supervisor. App, web and worker servers install Supervisor when they are provisioned. If it is missing, the Daemons tab says "Supervisor is not installed on this server" and explains that you need apt install supervisor before you reload the page. You can also add it from Manage services and restarts.
  • A command that works. Try it over SSH as the user you intend to use. Use absolute paths where possible, and set the directory so relative paths work.
  • A role that can create daemons on the server. Without it you can only read the list and the logs.

1. Read the daemon list

Open the server and choose Daemons. The page says "Background processes kept running by Supervisor, such as queue workers."

The Daemons tab
Every process Supervisor keeps alive for this server.
  1. New daemon. Opens the form to create one (step 2).
  2. Queue worker. A helper that builds the queue:work command of a Laravel app (step 3).
  3. Refresh status. Asks Supervisor for the current state of every daemon and updates the list.
  4. A daemon. The row shows its Name, its command, the User it runs as, the number of Processes and its Status: Running, Stopped, Starting, Stopping, Restarting, Failed, Creating, Deleting or Unknown. Search daemons and the Status filter narrow the list, and View chooses the columns.

The page checks that Supervisor is installed each time it loads. While that check runs, a skeleton is shown; if SrvYard cannot reach the server, the tab says "Could not check Supervisor" and offers Check again.

2. Create a daemon

Press New daemon. The panel explains that Supervisor keeps this process running and restarts it if it stops.

The New daemon panel
Everything Supervisor needs to start, watch and stop the process.
  1. Name. Lowercase letters, numbers, dashes and underscores. It names the Supervisor program, for example queue-reports.
  2. Command. One line, up to 1,000 characters. Line breaks are refused. For Laravel, use the full php artisan queue:work ... line, or let the Queue worker helper build it.
  3. Directory (optional). The working directory, an absolute path without ... For a Laravel site this is /home/srvyard/your-domain/current, so artisan is found. With zero-downtime releases current always points at the live release.
  4. Run as. srvyard, the user your sites run as, or root. Use srvyard unless you must.
  5. Processes. How many copies run side by side, from 1 to 50. Each copy is a separate process with its own memory. Start with 1 or 2 for queue workers and increase it only when the queue backs up.
  6. Start automatically and Restart when it exits. Both are on by default. The first starts the daemon when it is created and when the server boots; the second brings it back if it crashes or ends.
  7. Create daemon. Saves it and shows "Creating the daemon...". The row appears with the status Creating and turns Running when Supervisor has started it.

Further down, outside the screenshot: Start seconds (1 by default) is how long the process must stay up before Supervisor counts the start as successful, Stop wait seconds (10) is how long Supervisor waits after the Stop signal (TERM by default; INT, QUIT, KILL, HUP, USR1 and USR2 are also offered) before it kills the process, and Environment variables adds up to 50 KEY=value pairs only this process sees.

Tip

Queue workers keep the application code in memory. After a deployment they must be restarted to pick up the new code. For a Laravel site use php artisan queue:restart in the deploy script (see Write and test a deploy script), or restart the daemon from this tab.

3. Build a queue worker command

Press Queue worker for a form that writes the command for you. Fill it in, copy the command, then press Use in a new daemon to open New daemon with it filled in.

The Queue worker helper
The helper builds the queue:work command for you.
  1. PHP version. The PHP binary the command uses, for example /usr/bin/php8.4. Match your site.
  2. Connection. The queue connection from your .env, for example redis.
  3. Queues. A comma-separated list in priority order, for example high,default.
  4. Timeout (s). How long one job may run before the worker kills it. The helper also has Sleep (s), Rest (s), Backoff (s), Tries, Memory (MB), Environment and a Force switch (run even in maintenance mode). The Command at the bottom updates as you type.

Use the helper in a new daemon whose Directory is the application's folder. Keep the timeout shorter than your queue connection's retry-after setting, or a slow job may be picked up twice.

4. Control a daemon

Open the row menu (the three dots) of a daemon.

The row menu of a daemon
Control one daemon without touching the others.
  1. Start, Stop and Restart. Control the process through Supervisor. Restart is what you want after a deployment. The entries are disabled while another operation on that daemon is running.
  2. View logs. Opens the daemon's log file (its path is shown at the top) with the last lines.
  3. View status. What Supervisor reports for the program right now, process by process.
  4. Edit. The same form as for creating. Saving rewrites the Supervisor configuration and applies it.

Copy ID copies the daemon's identifier (useful with the API), and Delete asks for confirmation: "The process is stopped and its Supervisor configuration and log are removed from the server."

Warning

Deleting a queue worker stops it at once. Jobs that were running may be retried by another worker, so make sure your jobs can safely run twice.

Troubleshooting

  • "Supervisor is not installed on this server". The server was not provisioned with it (a database or cache server, for example). Install it from Services, then reload.
  • "Could not check Supervisor". SrvYard could not reach the server. Press Check again; if it keeps failing look at the server's Overview.
  • The status is Failed or keeps cycling between Starting and Stopping. The command exits straight away. Open View logs: the usual causes are a wrong directory, a missing .env, or a PHP version without the extensions the app needs. Run the same command over SSH as the same user to see the error.
  • The daemon runs old code after a deployment. Restart it from the row menu, or add php artisan queue:restart to the deploy script.
  • Changes in the form do not seem to apply. Wait for the status to leave Creating; the panel closes as soon as the request is accepted, not when Supervisor has restarted the program.
  • Name, directory or command is refused. Names allow lowercase letters, digits, dashes and underscores; the directory must be an absolute path without ..; the command must be a single line.
Last updated 2026-10-247 min readNeed help? Contact support