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

# Operate the daemon

> Start, monitor, scope, and stop the daemon host that runs your GitHub and Slack work.

The daemon runs GitHub and Slack work in the background on a machine you choose, the daemon host. Start it once, check it in the Daemon Monitor, and leave it running while you want requests handled.

The daemon is the first part of [automation setup](https://docs.embedder.com/headless/overview.md#set-up-automation). Start it, then connect [GitHub](https://docs.embedder.com/headless/github.md#connect-a-repository) and, if you want it, [Slack](https://docs.embedder.com/headless/slack.md#connect-slack).

## Prepare the host

* [Install Embedder](https://docs.embedder.com/cli/overview.md#install) on the host.
* Install the project's toolchain and any flashing or debugging tools the work needs.
* Connect the boards and instruments the work may use, or set up a [remote bridge](https://docs.embedder.com/integrations/remote-bridge.md).
* Record build, test and flash commands in [EMBEDDER.md](https://docs.embedder.com/core-concepts/embedder-md.md).
* Run `embedder` once and sign in with an Embedder account that belongs to the teams whose repositories this host should work on. The daemon only picks up work for those teams. On a host with no interactive terminal, [use an access token](#use-a-key-on-an-unattended-host) instead.

> [!WARNING]
>
> Daemon runs approve their own actions automatically. They can edit files, run commands and use any hardware the host can reach. Limit the host account to the access meant for automation, and state hardware limits in each request.

## Start the daemon

```bash theme={"theme":"css-variables"}
embedder start daemon
```

The command starts the daemon in the background, prints its PID and scope, then returns:

```text theme={"theme":"css-variables"}
Started Embedder daemon in the background.
  PID: 21004
  Scope: all linked repositories
Run `embedder monitor` to inspect it.
```

You can close the terminal. If a daemon is already running, the command says so and starts nothing new.

Run `embedder monitor` to open the Daemon Monitor, and check that the daemon's header shows **connected**. See [Monitor work](#monitor-work). Then [connect the GitHub repository](https://docs.embedder.com/headless/github.md#connect-a-repository), if it isn't connected yet.

The daemon doesn't start again by itself after the host restarts. Run `embedder start daemon` again after a reboot. To run the daemon under a service manager instead, use `embedder --daemon`, which stays in the foreground. See [Daemon commands](https://docs.embedder.com/headless/cli-reference.md#daemon-commands).

The daemon needs an API key. The command finds one in this order:

| Source | What happens |
| - | - |
| `EMBEDDER_API_KEY` in the environment | The daemon uses it. |
| A key saved by an earlier start | The daemon reuses it. |
| Your CLI sign-in | Embedder creates a key named `Embedder daemon <machine name>`, saves it, and prints `Created and stored a daemon API key from your current login.` Run `embedder` once to sign in. |
| None of these | The command asks you to paste a key. |

If a saved key is rejected, the command discards it and sets up a new one from the remaining sources.

### Use a key on an unattended host

On a host without an interactive terminal, either sign in once with `embedder` and then start the daemon, or provide a token in the environment:

1. In [the Embedder app](https://app.embedder.com), open **Settings**.
2. Under **Access tokens**, choose **Create token**, and enter a **Name**.
3. Choose an **Expiration**. The default is 90 days. When the token expires, the daemon stops authenticating until you give it a new one.
4. Choose **Create token**, then copy the token. It isn't shown again.
5. On the host, set it and start the daemon:

   ```bash theme={"theme":"css-variables"}
   export EMBEDDER_API_KEY="your-token"
   embedder start daemon
   ```

Keep the token out of repository files and request messages. If the daemon reports that authentication failed, check that the token is valid, hasn't expired and belongs to the intended account, then start it again.

## Restrict work to one project

By default, the daemon works on every mapped repository its account can reach. To limit it to one project, give both the team and project names:

```bash theme={"theme":"css-variables"}
embedder start daemon --team "Firmware Team" --project "sensor-hub"
```

Use the full names. Matching ignores case. Quote names with spaces. `EMBEDDER_TEAM` and `EMBEDDER_PROJECT` make the same selection through environment variables. Set both, or neither.

If a name doesn't match, the command reports it and lists the available names, for example `Team "Firmware" not found. Available: ...`.

The directory you start the daemon from doesn't matter. Each run checks out its mapped repository separately.

## Monitor work

```bash theme={"theme":"css-variables"}
embedder monitor
```

The **Daemon Monitor** refreshes every second and shows each running daemon:

| Section | What it shows |
| - | - |
| Header | Connection status, PID, uptime, current activity, and a **Stop** control. |
| **Session** | The model, with a **Change** control, plus the selected team and project. |
| **Work** | GitHub and Slack work, the current repository, and the last error. |
| **Workers** | How many runs are in progress out of the daemon's capacity, how long each has been running, and any time spent queued for hardware. |
| **Hardware** | Available serial ports, J-Link probes, and connected serial tabs. |

Common activity messages:

| Message | Meaning |
| - | - |
| **Idle**, or a message that starts with **Polling** | Connected and waiting for requests. |
| **Executing GitHub work** or **Executing Slack work** | A run is in progress. The repository name follows when known. |
| **Waiting for hardware** | A run is queued behind another run that is using a board. |
| **Waiting for local capacity** | All workers are busy. |
| **Waiting for GitHub reply** or **Waiting for Slack reply** | A run asked a question and is paused until someone answers. |
| **Waiting on another run** | Another run for the same pull request or Slack thread must finish first. |
| **Connecting to backend**, or a message that starts with **Reconnecting** | The daemon is connecting to Embedder, or retrying after it lost the connection. |
| **Authentication failed** | The API key was rejected. |

Daemon Monitor keys:

| Key | Action |
| - | - |
| `↑` `↓` or `j` `k` | Scroll |
| `PageUp` `PageDown`, `Home` `End` | Scroll by page, or to the top or bottom |
| `m` | Change the model, when one daemon is listed. In the list, choose a model with the arrow keys and `Enter`, or press its number. Press `Esc` to cancel. |
| `Esc`, `q` or `Ctrl+C` | Close the Daemon Monitor and leave the daemon running |

With several daemons listed, click **Change** in the daemon's **Session** section to change its model. The daemon applies the new model on its next status update and keeps it after a restart.

## Set parallel capacity

The daemon runs up to four requests at once. To change this, set `EMBEDDER_DAEMON_CONCURRENCY` to a positive whole number when you start it:

```bash theme={"theme":"css-variables"}
EMBEDDER_DAEMON_CONCURRENCY=8 embedder start daemon
```

Choose a value the host can support. An invalid value falls back to four. Requests for the same pull request or Slack thread still run one at a time. More capacity doesn't let two runs drive the same board at once.

## Keep runs within the time limit

Each run can take up to 30 minutes. Time spent waiting for hardware extends that limit by the time waited, up to 20 extra minutes. A run that goes past its limit stops and reports that it exceeded its duration ceiling.

Split long builds, investigations or soak tests into requests that finish within the limit. If a run stops at the limit, check its partial result and narrow the next request.

## Stop the daemon

```bash theme={"theme":"css-variables"}
embedder stop daemon
```

If more than one daemon is running, the command lists them. Pass the PID of the one to stop:

```bash theme={"theme":"css-variables"}
embedder stop daemon --pid 21004
```

You can also choose **Stop** in the Daemon Monitor. A run still in progress gets a few seconds to finish before it's stopped, so check **Workers** for active work before you stop the host.

## Troubleshoot

* **The Daemon Monitor shows No active daemon found:** start the daemon with `embedder start daemon`. Run `embedder monitor` under the same operating-system account that started the daemon.
* **No daemon API key found:** set `EMBEDDER_API_KEY`, or run `embedder` to sign in, then start the daemon again.
* **Connected but idle:** check that the repository is mapped to a project, that the daemon's account belongs to that project's team, and that `--team` and `--project` name the right project.
* **GitHub or Slack shows Waiting for a bench to take this, or No bench takes work for the repository yet:** no daemon picked up the request. In these replies, a bench is a machine running the daemon. Start one, then check the Daemon Monitor.
* **The project selection is rejected:** provide `--team` and `--project` together, with names from the list the command prints.
* **Waiting for local capacity:** let an active run finish, or raise `EMBEDDER_DAEMON_CONCURRENCY` if the host can support it.
* **Waiting for hardware:** find the run using the board in **Workers** before stopping anything.
* **Update the daemon: agent-owned publishing is required:** update Embedder on the host, then stop and start the daemon.
* **A run failed:** read the result in GitHub or Slack, fix the reported setup problem, and request a new run.
* **The duration ceiling was exceeded:** shorten the request, or split it into separate build, test and investigation requests.


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