diff --git a/olddocs/DEPLOYMENT.md b/olddocs/DEPLOYMENT.md index fe32a5c..62ef787 100644 --- a/olddocs/DEPLOYMENT.md +++ b/olddocs/DEPLOYMENT.md @@ -74,6 +74,55 @@ Database will be created at `data/cmdforge.db`. ### 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`: ```ini @@ -201,11 +250,12 @@ sqlite3 /opt/cmdforge/data/cmdforge.db ".backup '/backup/cmdforge.db'" ### Logs ```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/access.log - -# systemd logs journalctl -u cmdforge-web -f ``` @@ -224,16 +274,21 @@ curl http://localhost:5050/api/v1/tools ### Service won't start ```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 +sudo systemctl status cmdforge-web # Verify Python path -/opt/cmdforge/venv/bin/python -c "import cmdforge" +/path/to/cmdforge/venv/bin/python -c "import cmdforge" # Test gunicorn manually -cd /opt/cmdforge +cd /path/to/cmdforge 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