Critical fix for VPS/server deployments: - Gateway now uses user-level systemd (~/.config/systemd/user/) - Agent monitor uses system-level systemd (/etc/systemd/system/) - Added loginctl enable-linger requirement for persistence - Set XDG_RUNTIME_DIR and DBUS_SESSION_BUS_ADDRESS env vars - Updated deploy.sh with proper environment setup - Enhanced health check to verify linger and runtime dir - Updated agent-monitor.js with reliable gateway detection Documentation: - Added comprehensive systemd troubleshooting guide to MEMORY.md - Documented user-level vs system-level service architecture - Created deployment checklist for new servers - Added best practices for multi-agent deployments Files changed: - systemd/openclaw-gateway-user.service (new) - systemd/openclaw-agent-monitor.service (updated) - deploy.sh (complete rewrite of service management) - agent-monitor.js (improved gateway status checks) - MEMORY.md (added systemd troubleshooting guide)master
parent
820530d1ec
commit
3ad7de00b8
5 changed files with 276 additions and 32 deletions
@ -0,0 +1,51 @@ |
||||
# User-level systemd service for OpenClaw Gateway |
||||
# Install to: ~/.config/systemd/user/openclaw-gateway.service |
||||
# Required: loginctl enable-linger $(whoami) |
||||
|
||||
[Unit] |
||||
Description=OpenClaw Gateway (v2026.2.19-2) |
||||
After=network-online.target |
||||
Wants=network-online.target |
||||
|
||||
[Service] |
||||
Type=simple |
||||
ExecStart=/www/server/nodejs/v24.13.1/bin/node /www/server/nodejs/v24.13.1/lib/node_modules/openclaw/dist/index.js gateway --port 18789 |
||||
Restart=always |
||||
RestartSec=10 |
||||
StartLimitInterval=300 |
||||
StartLimitBurst=5 |
||||
KillMode=process |
||||
TimeoutStopSec=30 |
||||
|
||||
# Critical environment variables for user-level systemd |
||||
Environment=HOME=/root |
||||
Environment=XDG_RUNTIME_DIR=/run/user/0 |
||||
Environment=DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/0/bus |
||||
Environment=PATH=/root/.local/bin:/root/.npm-global/bin:/root/bin:/root/.volta/bin:/root/.asdf/shims:/root/.bun/bin:/root/.nvm/current/bin:/root/.fnm/current/bin:/root/.local/share/pnpm:/usr/local/bin:/usr/bin:/bin |
||||
Environment=OPENCLAW_GATEWAY_PORT=18789 |
||||
Environment=OPENCLAW_GATEWAY_TOKEN=9e2e91b31a56fb56a35e91821c025267292ec44c26169b12 |
||||
Environment=OPENCLAW_SYSTEMD_UNIT=openclaw-gateway.service |
||||
Environment=OPENCLAW_SERVICE_MARKER=openclaw |
||||
Environment=OPENCLAW_SERVICE_KIND=gateway |
||||
Environment=OPENCLAW_SERVICE_VERSION=2026.2.19-2 |
||||
|
||||
# Resource limits |
||||
MemoryLimit=2G |
||||
CPUQuota=80% |
||||
|
||||
# Security |
||||
NoNewPrivileges=true |
||||
ProtectSystem=strict |
||||
ProtectHome=read-only |
||||
ReadWritePaths=/root/.openclaw |
||||
|
||||
# Logging |
||||
StandardOutput=journal |
||||
StandardError=journal |
||||
SyslogIdentifier=openclaw-gateway |
||||
|
||||
# Watchdog |
||||
WatchdogSec=30 |
||||
|
||||
[Install] |
||||
WantedBy=default.target |
||||
Loading…
Reference in new issue