# How to Start the Code-Graph-RAG Daemon: A Complete CLI Guide

> Start the Code-Graph-RAG daemon easily with the cgr daemon up command. This guide provides a complete CLI walkthrough to launch the Docker-Compose stack for Memgraph and Qdrant.

- Repository: [Vitali Avagyan/code-graph-rag](https://github.com/vitali87/code-graph-rag)
- Tags: how-to-guide
- Published: 2026-09-06

---

**Use the `cgr daemon up` command to start the Code-Graph-RAG daemon, which launches a Docker-Compose stack containing Memgraph and Qdrant via the `StackManager` class.**

The Code-Graph-RAG daemon provides the backend infrastructure for graph-based retrieval-augmented generation operations. According to the `vitali87/code-graph-rag` source code, the daemon is orchestrated entirely through a CLI tool that wraps Docker-Compose operations, eliminating the need for manual container management.

## Prerequisites for Starting the Code-Graph-RAG Daemon

Before launching the daemon, ensure your environment meets two requirements.

- **Docker must be running** on your system. The daemon relies on containerized services defined in the repository's [`docker-compose.yml`](https://github.com/vitali87/code-graph-rag/blob/main/docker-compose.yml).
- **The package must be installed**. Install via pip:

```bash
pip install code-graph-rag

```

## Starting the Daemon with `cgr daemon up`

The primary command to start the Code-Graph-RAG daemon is `cgr daemon up`. This single command handles container creation, health checks, and service readiness.

```bash
cgr daemon up

```

Under the hood, this command performs several operations defined in the source code:

1. The CLI entry point in [`codebase_rag/cli.py`](https://github.com/vitali87/code-graph-rag/blob/main/codebase_rag/cli.py) registers the `daemon` command group and forwards calls to the stack CLI (lines 45-55).
2. The `up` sub-command in [`codebase_rag/stack/cli.py`](https://github.com/vitali87/code-graph-rag/blob/main/codebase_rag/stack/cli.py) instantiates `StackManager` and invokes `ensure_running()` (lines 34-41).
3. The `StackManager` class in [`codebase_rag/stack/manager.py`](https://github.com/vitali87/code-graph-rag/blob/main/codebase_rag/stack/manager.py) builds the Docker-Compose project, starts the Memgraph and Qdrant containers, and polls health endpoints until services are ready.

## Verifying Daemon Status

Confirm the daemon is running with the status command:

```bash
cgr daemon status

```

This outputs the current state, service endpoints for Memgraph and Qdrant, and the path to the Compose file. The implementation calls `StackManager.status()` and `warn_if_ports_are_public()` in [`codebase_rag/stack/cli.py`](https://github.com/vitali87/code-graph-rag/blob/main/codebase_rag/stack/cli.py) (lines 58-65).

## Monitoring Daemon Logs

For troubleshooting or observability, view container logs through the CLI:

```bash
cgr daemon logs              # Show all services

cgr daemon logs -f           # Follow logs in real-time

cgr daemon logs -s memgraph  # Show only Memgraph logs

```

The logs command forwards to `StackManager.logs()` as implemented in [`codebase_rag/stack/cli.py`](https://github.com/vitali87/code-graph-rag/blob/main/codebase_rag/stack/cli.py) (lines 80-92).

## Stopping the Daemon

When you no longer need the services, shut down the stack cleanly:

```bash
cgr daemon down

```

This command triggers the Docker-Compose shutdown sequence through `StackManager` (lines 46-53 in [`codebase_rag/stack/cli.py`](https://github.com/vitali87/code-graph-rag/blob/main/codebase_rag/stack/cli.py)).

## Complete Command Reference

| Command | Purpose |
|---------|---------|
| `cgr daemon up` | Starts the Docker-Compose stack and waits for healthy state |
| `cgr daemon down` | Stops and removes all containers |
| `cgr daemon status` | Displays running state and endpoints |
| `cgr daemon restart` | Restarts the entire stack |
| `cgr daemon logs` | Shows or follows container logs |

## Key Implementation Files

Understanding the source structure helps with debugging or extending the daemon:

- **[`codebase_rag/cli.py`](https://github.com/vitali87/code-graph-rag/blob/main/codebase_rag/cli.py)** — Top-level CLI registration, delegates to stack commands
- **[`codebase_rag/stack/cli.py`](https://github.com/vitali87/code-graph-rag/blob/main/codebase_rag/stack/cli.py)** — Implements `up`, `down`, `status`, `restart`, and `logs` sub-commands
- **[`codebase_rag/stack/manager.py`](https://github.com/vitali87/code-graph-rag/blob/main/codebase_rag/stack/manager.py)** — Core `StackManager` class handling Docker-Compose orchestration and health checks

## Summary

- **Install** with `pip install code-graph-rag` and ensure Docker is running
- **Start** the Code-Graph-RAG daemon using `cgr daemon up`, which invokes `StackManager.ensure_running()`
- **Monitor** with `cgr daemon status` and `cgr daemon logs` commands
- **Stop** cleanly with `cgr daemon down` when finished
- The daemon stack comprises **Memgraph** (graph database) and **Qdrant** (vector database) containers orchestrated via Docker-Compose

## Frequently Asked Questions

### What services run inside the Code-Graph-RAG daemon?

The daemon manages two containerized services: **Memgraph** for graph storage and **Qdrant** for vector embeddings. Both are defined in the repository's [`docker-compose.yml`](https://github.com/vitali87/code-graph-rag/blob/main/docker-compose.yml) and orchestrated by the `StackManager` class.

### Why does `cgr daemon up` hang or timeout?

The command waits for health checks to pass. If Docker is not running, ports are already in use, or containers fail to start, `ensure_running()` will retry until timeout. Run `cgr daemon logs` to diagnose startup failures.

### Can I run the daemon without the CLI?

While possible by invoking `docker-compose` directly on the repository's compose file, the CLI provides essential functionality including automated health checking, status reporting, and log aggregation through `StackManager`.