# Manage the daemon

Canonical: https://hypaware.ai/docs/cli-reference/manage-the-daemon

```text
hyp daemon <subcommand> [args...]
```

Use `hyp daemon --help` to list service operations:

```sh
hyp daemon --help
```

Daemon commands don't activate plugins.

## `hyp daemon install`

```text
hyp daemon install [--config <path>] [--bin <path>] [--force] [--dry-run [--json]]
```

Installs the persistent launchd or systemd user service. When invoked from an
ephemeral `npx` path, it installs a durable global package before it writes the
service. `--force` allows the existing CLI path if that global installation
fails; removing that directory later can break capture. `--dry-run` renders
the exact service definition without changing the host; add `--json` for
structured plan output.

```sh
hyp daemon install --dry-run --json
```

## `hyp daemon uninstall`

```text
hyp daemon uninstall
```

**Warning:** This command stops persistent capture and detaches clients. Check
`hyp status` before you uninstall the daemon so you know which clients it
changes.

Removes the persistent service, then detaches every attached client so no
client points at a dead gateway. It keeps configuration, recordings, and logs.
The command doesn't ask for confirmation. If service removal succeeds but a
detach fails, the command returns `1` and prints the detach command needed to
finish.

```sh
hyp daemon uninstall
```

## `hyp daemon run`

```text
hyp daemon run [--config <path>]
```

Runs the daemon in the current terminal until it receives a stop signal.
`daemon start` starts the installed service.

When the daemon applies a new organization configuration or a plugin change,
it restarts as a new process to load the new code. An installed service
relaunches it automatically. A foreground run with no service manager (a
container, say) relaunches itself with the same arguments, environment and
output, up to 5 times in 10 minutes, waiting a little longer each time. Past
that it stops, prints the staged configuration it was applying, and exits with
code `75`. A run under systemd or launchd, or started by a Node process manager
such as pm2, exits with `75` on every restart instead and leaves the relaunch to
it. To keep relaunching after the limit, run it again on `75`. This loop does
that and exits with the daemon's own status otherwise, so a supervisor still
sees a failed start:

```sh
rc=75
while [ "$rc" -eq 75 ]; do hyp daemon run && rc=0 || rc=$?; done
exit "$rc"
```

The first daemon start after `hyp join` or `hyp remote login --no-daemon`
usually takes this path, because that is when the organization configuration
arrives.

```sh
hyp daemon run
```

## `hyp daemon start`

```text
hyp daemon start
```

Starts the installed service. It returns `1` if no service is installed or the
service manager can't start it.

```sh
hyp daemon start
```

## `hyp daemon status`

```text
hyp daemon status [--json]
```

Reads the daemon status and process ID files without activating plugins. A
missing status file prints `not started` and returns `0`. Malformed status or
read failures return `1`.

```sh
hyp daemon status --json
```

## `hyp daemon stop`

```text
hyp daemon stop
```

Signals the running daemon and waits up to five seconds. An already stopped
daemon succeeds. A timeout returns `1`.

```sh
hyp daemon stop
```

## `hyp daemon restart`

```text
hyp daemon restart [--processing]
```

Restarts an installed service. If no service is installed, it stops a
foreground daemon and tells you how to relaunch or install it.

`--processing` replaces only the supervised processing daemon (recording,
sinks, backfill and maintenance) and leaves the gateway listener, its sockets
and its in-flight streams alone. It asks the running gateway to bounce its
child and returns as soon as the request is written; the gateway allows the
child four seconds to stop before killing it. With no gateway supervising a
processing daemon it prints that and returns `1`.

```sh
hyp daemon restart
hyp daemon restart --processing
```

