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

# Daemon Overview

> Always-on background process for scheduled automations

The Fliiq daemon is a background process that runs scheduled jobs, listens for Telegram messages, and exposes a health API. It's a thin FastAPI server that spawns agent loops — each job runs independently.

## Starting the Daemon

```bash theme={null}
# Foreground (see logs in terminal)
fliiq daemon start

# Detached (runs in background)
fliiq daemon start --detach
```

## Managing the Daemon

```bash theme={null}
fliiq daemon status     # Check if running, show Telegram status
fliiq daemon stop       # Graceful shutdown
fliiq daemon restart    # Stop + start
```

## What the Daemon Does

1. **Loads jobs** from `.fliiq/jobs/*.yaml`
2. **Schedules timers** for each job based on trigger config (cron, interval, one-shot)
3. **Executes jobs** by spawning fresh `agent_loop()` calls with the job's prompt and skills
4. **Listens for Telegram** messages (if `TELEGRAM_BOT_TOKEN` is set) and **email** (if Gmail credentials are configured) — all channel listeners use a shared persistent session store so conversation context is preserved across job runs and restarts, for every channel
5. **Exposes health API** at `http://localhost:7890/health`

## Architecture

Each job execution is isolated:

* Fresh `agent_loop()` call — no shared message history with interactive sessions
* Independent — multiple jobs can run simultaneously
* Per-job memory at `.fliiq/memory/jobs/<name>.md`
* Audit trails saved automatically

The daemon doesn't block interactive use. You can run `fliiq` while the daemon runs jobs in the background.

<Warning>
  **Telegram prerequisite:** If `TELEGRAM_BOT_TOKEN` is set in your `.env`, you must also set `TELEGRAM_ALLOWED_CHAT_IDS`. The daemon will refuse to start without it. Run `fliiq telegram setup` to configure this interactively — see [Telegram setup](/channels/telegram#setup) for details.
</Warning>

## Auto-Restart on Upgrade

When Fliiq is upgraded to a new version (e.g. via `pip install --upgrade fliiq`), the daemon detects the version change and automatically restarts itself to pick up the new code. No manual intervention needed — the daemon comes back up on the new version without dropping any scheduled jobs.

## Retry Behavior

If a job fails (API timeout, LLM error):

* **Transient retry**: 3 attempts with 30s/60s backoff
* **Startup retry**: If a job's last run failed and the daemon restarts, the job fires immediately instead of waiting for its next scheduled window
* **Failure notifications**: If a job exhausts all retries, the daemon sends a Telegram notification automatically (requires `TELEGRAM_BOT_TOKEN` and `TELEGRAM_ALLOWED_CHAT_IDS` to be configured)

## Health Endpoint

```bash theme={null}
curl http://localhost:7890/health
```

Returns daemon status including active jobs and Telegram listener status.

## Next Steps

* [Creating Jobs](/daemon/jobs) — Define scheduled automations
* [Triggers](/daemon/triggers) — Cron, interval, one-shot, and webhook triggers
* [Delivery](/daemon/delivery) — Send job results via email, SMS, or Telegram
