To run your **Kotaemon setup** as a **systemd service on Ubuntu** (so it autostarts on boot), you can create a custom service file like this:
---
### ✅ 1. **Create a systemd service file**
Save this as:
`/etc/systemd/system/kotaemon.service`
```ini
[Unit]
Description=Kotaemon RAG Service
After=network.target
[Service]
Type=simple
User=manfred
WorkingDirectory=/home/manfred/kotaemon
Environment=HF_TOKEN=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
Environment=GRADIO_SERVER_NAME=0.0.0.0
Environment=share=True
Environment=RAG_BACKEND=ollama
Environment=USE_LIGHTRAG=true
ExecStart=/bin/bash -c 'source /home/manfred/miniconda3/etc/profile.d/conda.sh && conda activate kotaemon && dotenv run python app.py'
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.target
```
---
### ✅ 2. **Reload systemd and enable the service**
```bash
sudo systemctl daemon-reexec
sudo systemctl daemon-reload
sudo systemctl enable kotaemon.service
sudo systemctl start kotaemon.service
```
---
### ✅ 3. **Check status / logs**
```bash
sudo systemctl status kotaemon.service
journalctl -u kotaemon.service -f
```
---
### 🔐 Notes:
- Make sure `conda` is initialized for non-interactive shells (you’re using `source ...conda.sh`)
- Ensure `dotenv` is installed in the `kotaemon` conda env
- File permissions: `/home/manfred/kotaemon` and all its contents must be readable by user `manfred`
---
Möchtest du zusätzlich einen **watchdog/restart timer** oder eine **log rotation** für stdout/stderr einbauen?