How to Start the Code-Graph-RAG Daemon: A Complete CLI Guide
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. - The package must be installed. Install via pip:
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.
cgr daemon up
Under the hood, this command performs several operations defined in the source code:
- The CLI entry point in
codebase_rag/cli.pyregisters thedaemoncommand group and forwards calls to the stack CLI (lines 45-55). - The
upsub-command incodebase_rag/stack/cli.pyinstantiatesStackManagerand invokesensure_running()(lines 34-41). - The
StackManagerclass incodebase_rag/stack/manager.pybuilds 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:
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 (lines 58-65).
Monitoring Daemon Logs
For troubleshooting or observability, view container logs through the CLI:
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 (lines 80-92).
Stopping the Daemon
When you no longer need the services, shut down the stack cleanly:
cgr daemon down
This command triggers the Docker-Compose shutdown sequence through StackManager (lines 46-53 in 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— Top-level CLI registration, delegates to stack commandscodebase_rag/stack/cli.py— Implementsup,down,status,restart, andlogssub-commandscodebase_rag/stack/manager.py— CoreStackManagerclass handling Docker-Compose orchestration and health checks
Summary
- Install with
pip install code-graph-ragand ensure Docker is running - Start the Code-Graph-RAG daemon using
cgr daemon up, which invokesStackManager.ensure_running() - Monitor with
cgr daemon statusandcgr daemon logscommands - Stop cleanly with
cgr daemon downwhen 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 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.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →