yangdx commited on
Commit
74261de
·
1 Parent(s): 9371b8e

Install Lightrag as a Linux Service (sample files and installation guide)

Browse files
lightrag/api/README.md CHANGED
@@ -342,7 +342,7 @@ curl http://localhost:9621/api/tags
342
 
343
  Handle chat completion requests
344
 
345
- ```
346
  curl -N -X POST http://localhost:9621/api/chat -H "Content-Type: application/json" -d \
347
  '{"model":"lightrag:latest","messages":[{"role":"user","content":"猪八戒是谁"}],"stream":true}'
348
  ```
@@ -424,3 +424,34 @@ This intelligent caching mechanism:
424
  - Only new documents in the input directory will be processed
425
  - This optimization significantly reduces startup time for subsequent runs
426
  - The working directory (`--working-dir`) stores the vectorized documents database
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
342
 
343
  Handle chat completion requests
344
 
345
+ ```shell
346
  curl -N -X POST http://localhost:9621/api/chat -H "Content-Type: application/json" -d \
347
  '{"model":"lightrag:latest","messages":[{"role":"user","content":"猪八戒是谁"}],"stream":true}'
348
  ```
 
424
  - Only new documents in the input directory will be processed
425
  - This optimization significantly reduces startup time for subsequent runs
426
  - The working directory (`--working-dir`) stores the vectorized documents database
427
+
428
+ ## Install Lightrag as a Linux Service
429
+
430
+ Create your service file: `lightrag.sevice`. Modified the following lines from `lightrag.sevice.example`
431
+
432
+ ```text
433
+ Description=LightRAG Ollama Service
434
+ WorkingDirectory=<lightrag installed directory>
435
+ ExecStart=<lightrag installed directory>/lightrag/api/start_lightrag.sh
436
+ ```
437
+
438
+ Create your service startup script: `start_lightrag.sh`. Change you python virtual environment activation method as need:
439
+
440
+ ```shell
441
+ #!/bin/bash
442
+
443
+ # python virtual environment activation
444
+ source /home/netman/lightrag-xyj/venv/bin/activate
445
+ # start lightrag api server
446
+ lightrag-server
447
+ ```
448
+
449
+ Install lightrag.service in Linux. Sample commands in Ubuntu server look like:
450
+
451
+ ```shell
452
+ sudo cp lightrag-server.service /etc/systemd/system/
453
+ sudo systemctl daemon-reload
454
+ sudo systemctl start lightrag-server.service
455
+ sudo systemctl status lightrag-server.service
456
+ sudo systemctl enable lightrag-server.service
457
+ ```
lightrag/api/lightrag.service.example ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [Unit]
2
+ Description=LightRAG XYJ Ollama Service
3
+ After=network.target
4
+
5
+ [Service]
6
+ Type=simple
7
+ User=netman
8
+ # Memory settings
9
+ MemoryHigh=8G
10
+ MemoryMax=12G
11
+ WorkingDirectory=/home/netman/lightrag-xyj
12
+ ExecStart=/home/netman/lightrag-xyj/lightrag/api/start_lightrag_server.sh
13
+ Restart=always
14
+ RestartSec=10
15
+
16
+ [Install]
17
+ WantedBy=multi-user.target
lightrag/api/start_lightrag.sh.example ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ source /home/netman/lightrag-xyj/venv/bin/activate
4
+ lightrag-server