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

# Run several daemons and accounts on one computer

> Run one Reliant daemon per checkout or per account on the same computer, see which instance each directory maps to, and check, read or stop any of them by name.

By the end of this guide you can run more than one Reliant daemon on one computer, for example one per checkout or one for each of two accounts, and check, read or stop any of them from any directory.

Each daemon is an **instance**, named by three things: the server it talks to, the account it runs as, and the workspace it serves. Every combination gets its own folder under `~/.reliant/instances/<server>/<account>/<workspace>/`, with its runtime record, its daemon id and its logs ([one daemon per workspace](https://docs.reliantlabs.io/machines/your-computer.md#one-daemon-per-workspace)). Each instance connects as a separate machine.

## Before you begin

* The `reliant` CLI on the computer ([Installation](https://docs.reliantlabs.io/getting-started/installation.md)).
* One daemon already paired ([connect your computer](https://docs.reliantlabs.io/guides/machines/connect-computer-as-machine.md)). Pairing a new account needs you to approve a code in the app.

**1. See which instance a directory maps to**

The workspace defaults to the git worktree root of the current directory, so `status` answers for a different instance in each checkout:

```bash terminal theme={null}
cd ~/src/repo-a/src && reliant daemon status
cd ~/src/repo-b && reliant daemon status
```

```text terminal theme={null}
No daemon running (no runtime record found)
  Record:   ~/.reliant/instances/https-api.reliantapi.com-c9232e15/_default/repo-a-d194cf53/daemon-state.json
daemon not running
No daemon running (no runtime record found)
  Record:   ~/.reliant/instances/https-api.reliantapi.com-c9232e15/_default/repo-b-4622c772/daemon-state.json
daemon not running
```

The first was run from a subdirectory and still names `repo-a`. `_default` is the account segment before you use more than one account. Outside a git checkout, the workspace is the current directory itself. `status` only looks: it creates nothing, and it exits `1` until a daemon's stream is connected.

**2. Start a daemon for another checkout**

```bash terminal theme={null}
cd ~/src/repo-b
reliant daemon start --name repo-b-box
```

The credential in `~/.reliant/daemon.json` belongs to an account, not to a checkout, so the new instance uses it and saves a daemon id of its own. The machine appears in **Settings → Machines** under the `--name` you gave it. Each daemon runs in the foreground: give each one its own terminal, `tmux` window or service unit ([run the daemon on your own server](https://docs.reliantlabs.io/guides/machines/run-agents-on-your-own-server.md)).

**3. Start a daemon for a second account**

Name the account, by user id, on every command for that daemon. `reliant auth status` shows the account of a `reliant auth login` made by a recent release:

```bash terminal theme={null}
reliant daemon start --account <user-id>
```

An account with no stored credential pairs first. Approve the code while signed in to the app as that account. With `--token`, the daemon runs as whichever account the pasted token belongs to. Without either, the most recently connected account is used. When you are signed in with `reliant auth login`, `daemon start` passes over another account's stored credential and pairs the computer as you instead. Two accounts can run side by side, even in the same checkout:

```text terminal theme={null}
Record:   ~/.reliant/instances/https-api.reliantapi.com-c9232e15/usr_alice-188a1a5e/repo-a-d194cf53/daemon-state.json
```

**4. List every instance**

```bash terminal theme={null}
reliant daemon ls
```

Here three daemons have started, none of them signed in yet:

```text terminal theme={null}
RUNNING  PID     STREAM                UPTIME  INSTANCE
-        637043  awaiting_credentials  17s     https-api.reliantapi.com-c9232e15/_default/repo-a-d194cf53
-        637035  awaiting_credentials  17s     https-api.reliantapi.com-c9232e15/_default/repo-b-4622c772
-        637036  awaiting_credentials  17s     https-api.reliantapi.com-c9232e15/usr_alice-188a1a5e/repo-a-d194cf53
```

**RUNNING** comes from a lock the operating system releases when the process dies, so it can't be stale. A daemon takes that lock once it has a credential and starts serving, so a daemon still signing in shows `-`. A connected one looks like this:

```text terminal theme={null}
RUNNING  PID    STREAM     UPTIME     INSTANCE
yes      21208  connected  28h47m57s  https-api.reliantapi.com-c9232e15/_default/workspace-b45e3fc5
```

**5. Check, read or stop any instance from anywhere**

`status`, `logs` and `stop` take the same `--workspace`, `--account` and `--server` as `start`, so you can address any instance from any directory:

```bash terminal theme={null}
reliant daemon status --workspace ~/src/repo-a --account usr_alice
reliant daemon logs   --workspace ~/src/repo-b -n 100
reliant daemon stop   --workspace ~/src/repo-a --account usr_alice
```

```text terminal theme={null}
Stopping daemon (PID 637036)...
Daemon stopped (PID 637036 exited)
```

`stop` waits for the process to exit and exits `0` once it has. A different `--server` is a different instance too: `--server http://localhost:8080` gives a record under `http-localhost-8080-a76d8c3e/`.

**6. Check that each daemon is connected**

Run `reliant daemon status` for each instance. It exits `0` only when that daemon's stream is established and stable, and each one shows as a connected machine in **Settings → Machines**.

## What this does not do

* **A workspace isn't a sandbox.** It names the instance. Every daemon runs as your Unix user, and an agent's shell command can reach whatever that user can ([daemon security model](https://docs.reliantlabs.io/deep-dives/daemon-security-model.md)).
* **Accounts that share a Unix user share its files.** Both accounts' credentials are in the same `~/.reliant/daemon.json`, and an agent's shell command under either daemon can read it. Give two people separate Unix users, not separate `--account` daemons.
* **A daemon that is still signing in doesn't block a second start** in the same instance, because it hasn't taken the lock yet. Stop it with `reliant daemon stop` before you start another there.

## Next steps

> [card] [Run a machine from the CLI](https://docs.reliantlabs.io/cli/run-a-machine.md)
>
> Start, check, read logs and stop a daemon, with a systemd unit.

> [card] [Fix an offline machine](https://docs.reliantlabs.io/guides/machines/troubleshoot-offline-machine.md)
>
> Read the stream state and re-register a refused credential.

> [card] [Daemon security model](https://docs.reliantlabs.io/deep-dives/daemon-security-model.md)
>
> Instance identity, `daemon.json` and what a command can reach.

> [card] [Reclaim and restore worktrees](https://docs.reliantlabs.io/guides/machines/reclaim-restore-worktrees.md)
>
> Free the disk each machine's worktrees hold.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.