2024-09-26 16:15:57 +08:00
---
sidebar_position: 2
slug: /launch_ragflow_from_source
---
2025-03-06 09:55:27 +08:00
# Launch service from source
2024-09-26 16:15:57 +08:00
A guide explaining how to set up a RAGFlow service from its source code. By following this guide, you'll be able to debug using the source code.
2025-03-04 19:21:28 +08:00
## Target audience
2024-09-26 16:15:57 +08:00
Developers who have added new features or modified existing code and wish to debug using the source code, *provided that* their machine has the target deployment environment set up.
## Prerequisites
- CPU ≥ 4 cores
- RAM ≥ 16 GB
- Disk ≥ 50 GB
- Docker ≥ 24.0.0 & Docker Compose ≥ v2.26.1
:::tip NOTE
If you have not installed Docker on your local machine (Windows, Mac, or Linux), see the [Install Docker Engine ](https://docs.docker.com/engine/install/ ) guide.
:::
2025-03-04 19:21:28 +08:00
## Launch a service from source
2024-09-26 16:15:57 +08:00
2025-03-04 19:21:28 +08:00
To launch a RAGFlow service from source code:
2024-09-26 16:15:57 +08:00
2025-03-04 19:21:28 +08:00
### Clone the RAGFlow repository
2024-09-26 16:15:57 +08:00
```bash
git clone https://github.com/infiniflow/ragflow.git
cd ragflow/
```
### Install Python dependencies
2025-01-14 11:49:43 +08:00
1. Install uv:
2024-09-26 16:15:57 +08:00
```bash
2025-01-14 11:49:43 +08:00
pipx install uv
2024-09-26 16:15:57 +08:00
```
2025-01-14 11:49:43 +08:00
2. Install Python dependencies:
2024-12-13 17:58:01 +07:00
- slim:
2024-09-26 16:15:57 +08:00
```bash
2025-01-14 11:49:43 +08:00
uv sync --python 3.10 # install RAGFlow dependent python modules
2024-09-26 16:15:57 +08:00
```
2024-12-13 17:58:01 +07:00
- full:
```bash
2025-01-14 11:49:43 +08:00
uv sync --python 3.10 --all-extras # install RAGFlow dependent python modules
2024-12-13 17:58:01 +07:00
```
2024-09-26 16:15:57 +08:00
*A virtual environment named `.venv` is created, and all Python dependencies are installed into the new environment.*
2025-03-04 19:21:28 +08:00
### Launch third-party services
2024-09-26 16:15:57 +08:00
The following command launches the 'base' services (MinIO, Elasticsearch, Redis, and MySQL) using Docker Compose:
```bash
docker compose -f docker/docker-compose-base.yml up -d
```
### Update `host` and `port` Settings for Third-party Services
2024-11-12 15:56:53 +01:00
1. Add the following line to `/etc/hosts` to resolve all hosts specified in **docker/service_conf.yaml.template** to `127.0.0.1` :
2024-09-26 16:15:57 +08:00
```
2024-11-12 14:59:41 +08:00
127.0.0.1 es01 infinity mysql minio redis
2024-09-26 16:15:57 +08:00
```
2024-11-12 15:56:53 +01:00
2. In **docker/service_conf.yaml.template** , update mysql port to `5455` and es port to `1200` , as specified in **docker/.env** .
2024-09-26 16:15:57 +08:00
2025-03-04 19:21:28 +08:00
### Launch the RAGFlow backend service
2024-09-26 16:15:57 +08:00
1. Comment out the `nginx` line in **docker/entrypoint.sh** .
```
# /usr/sbin/nginx
```
2. Activate the Python virtual environment:
```bash
source .venv/bin/activate
export PYTHONPATH=$(pwd)
```
3. **Optional:** If you cannot access HuggingFace, set the HF_ENDPOINT environment variable to use a mirror site:
```bash
export HF_ENDPOINT=https://hf-mirror.com
```
2025-03-14 14:20:18 +08:00
4. Check the configuration in **conf/service_conf.yaml** , ensuring all hosts and ports are correctly set.
5. Run the **entrypoint.sh** script to launch the backend service:
2024-09-26 16:15:57 +08:00
2025-03-14 14:20:18 +08:00
```shell
JEMALLOC_PATH=$(pkg-config --variable=libdir jemalloc)/libjemalloc.so;
LD_PRELOAD=$JEMALLOC_PATH python rag/svr/task_executor.py 1;
2024-09-26 16:15:57 +08:00
```
2025-03-14 14:20:18 +08:00
```shell
python api/ragflow_server.py;
2024-09-26 16:15:57 +08:00
```
### Launch the RAGFlow frontend service
1. Navigate to the `web` directory and install the frontend dependencies:
```bash
cd web
2024-12-30 18:19:58 +08:00
npm install
2024-09-26 16:15:57 +08:00
```
2. Update `proxy.target` in ** .umirc.ts** to `http://127.0.0.1:9380` :
```bash
vim .umirc.ts
```
3. Start up the RAGFlow frontend service:
```bash
npm run dev
2024-09-29 10:51:46 +08:00
```
2024-09-26 16:15:57 +08:00
*The following message appears, showing the IP address and port number of your frontend service:*

### Access the RAGFlow service
2024-09-29 10:51:46 +08:00
In your web browser, enter `http://127.0.0.1:<PORT>/` , ensuring the port number matches that shown in the screenshot above.
### Stop the RAGFlow service when the development is done
1. Stop the RAGFlow frontend service:
```bash
pkill npm
```
2. Stop the RAGFlow backend service:
```bash
pkill -f "docker/entrypoint.sh"
2024-12-13 17:58:01 +07:00
```