Update deployment docs with user systemd service option

Add documentation for running as a user service (systemctl --user)
which is how the current OMV deployment is configured. The previous
docs only showed system service setup which caused confusion.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
rob 2026-01-13 23:16:34 -04:00
parent 946a5933b4
commit 58f187ccad
1 changed files with 62 additions and 7 deletions

View File

@ -74,6 +74,55 @@ Database will be created at `data/cmdforge.db`.
### 4. systemd Service ### 4. systemd Service
You can run as either a **system service** (requires root) or a **user service** (no root needed).
#### Option A: User Service (Recommended for personal servers)
Create `~/.config/systemd/user/cmdforge-web.service`:
```ini
[Unit]
Description=CmdForge Registry Web Application
After=network.target
[Service]
Type=simple
WorkingDirectory=/path/to/cmdforge
Environment="PATH=/path/to/cmdforge/venv/bin"
Environment="CMDFORGE_REGISTRY_DB=/tmp/cmdforge-data/registry.db"
ExecStartPre=/path/to/cmdforge/scripts/db-restore.sh
ExecStart=/path/to/cmdforge/venv/bin/gunicorn \
-c gunicorn.conf.py \
cmdforge.web.app:create_web_app()
Restart=always
RestartSec=5
[Install]
WantedBy=default.target
```
Enable and start:
```bash
# Enable lingering (so service runs without login)
loginctl enable-linger $USER
# Reload and enable
systemctl --user daemon-reload
systemctl --user enable cmdforge-web
systemctl --user start cmdforge-web
# Check status
systemctl --user status cmdforge-web
# View logs
journalctl --user -u cmdforge-web -f
```
**Note:** The current OMV deployment uses this approach.
#### Option B: System Service (Traditional deployment)
Create `/etc/systemd/system/cmdforge-web.service`: Create `/etc/systemd/system/cmdforge-web.service`:
```ini ```ini
@ -201,11 +250,12 @@ sqlite3 /opt/cmdforge/data/cmdforge.db ".backup '/backup/cmdforge.db'"
### Logs ### Logs
```bash ```bash
# Application logs # For user service (OMV deployment)
journalctl --user -u cmdforge-web -f
# For system service
tail -f /var/log/cmdforge/error.log tail -f /var/log/cmdforge/error.log
tail -f /var/log/cmdforge/access.log tail -f /var/log/cmdforge/access.log
# systemd logs
journalctl -u cmdforge-web -f journalctl -u cmdforge-web -f
``` ```
@ -224,16 +274,21 @@ curl http://localhost:5050/api/v1/tools
### Service won't start ### Service won't start
```bash ```bash
# Check logs # For user service
journalctl --user -u cmdforge-web -n 50
systemctl --user status cmdforge-web
# For system service
journalctl -u cmdforge-web -n 50 journalctl -u cmdforge-web -n 50
sudo systemctl status cmdforge-web
# Verify Python path # Verify Python path
/opt/cmdforge/venv/bin/python -c "import cmdforge" /path/to/cmdforge/venv/bin/python -c "import cmdforge"
# Test gunicorn manually # Test gunicorn manually
cd /opt/cmdforge cd /path/to/cmdforge
source venv/bin/activate source venv/bin/activate
gunicorn --bind 127.0.0.1:5050 'cmdforge.web.app:create_app()' gunicorn -c gunicorn.conf.py 'cmdforge.web.app:create_web_app()'
``` ```
### Database errors ### Database errors