> ## Documentation Index
> Fetch the complete documentation index at: https://docs.shipways.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Daemons

> Long-running processes Supervisor keeps alive.

A daemon is anything that should be running all the time: a queue worker,
Horizon, a Node process behind a proxied site, a websocket server.

Supervisor manages them. It starts them at boot, restarts them if they stop,
and asks them to finish rather than killing them on a restart.

Daemons live on the **server's** Processes tab. A site's Processes tab shows
the same rows read-only, because these are written under the server's
permission rather than the site's — a second set of controls behind the weaker
permission would be a way of acquiring the stronger one.

## Adding one

**Command** — the full command line. Use the **full path to PHP**,
`/usr/bin/php8.4 artisan queue:work`, rather than `php`. Bare `php` gets
[the machine's CLI default](/servers/php#the-cli-default), which may not be the
version the site runs.

**Directory** — where it runs, normally the site's `current` symlink so that
restarting after a deploy picks up the new release.

**Processes** — how many copies to run. Four queue workers is four processes of
one daemon rather than four daemons.

**Name** is yours, and is what the daemon's log file is named after.

## The queue worker shortcut

A site with a queue worker in its [capabilities](/sites/kinds#what-runs-behind-a-site)
offers **Add queue worker**, which fills the command, the directory and the PHP
version in from the site. It is the same daemon either way.

## Restarting and deploying

Saving a daemon rewrites its Supervisor program and restarts it.

A restart signals the process rather than killing it, and waits. A queue worker
given that signal finishes the job it is holding and exits, which is the
difference between a clean restart and a job that runs twice.

The whole group goes down together, so a restart never leaves one of four
workers running the previous release.

<Note>
  A deployment does not restart daemons. A queue worker holds its code and its
  configuration until it restarts, so a deploy that changes either needs the
  worker restarting — either from here, or with `queue:restart` in the
  [deploy script](/sites/deploy-script).
</Note>

## Logs

Each daemon writes to its own file under `/var/log/shipways`, readable from the
row and from the [Logs tab](/servers/logs). They are rotated weekly, and four
weeks are kept — logs from a daemon restarting in a loop will fill a disk given
long enough.

## When one stops

A daemon that Supervisor has given up on [opens an alert](/alerts). That is
worth having: a queue worker that exits immediately on every start looks
exactly like one that is running fine, from anywhere but here.
