diff --git a/docs/server-AGENTS.md b/docs/server-AGENTS.md index a898378..3800d73 100644 --- a/docs/server-AGENTS.md +++ b/docs/server-AGENTS.md @@ -102,6 +102,50 @@ Other agents may have similar sandbox settings - check their docs if nix command - Fork-bomb or stress test (watchdogs will kill you) - Store secrets in plain files (use env vars) +## Running Persistent Services + +Three options for keeping code running: + +### 1. tmux/screen (simplest) +```bash +tmux new -s mybot +python bot.py +# Ctrl-b d to detach, tmux attach -t mybot to reconnect +``` + +### 2. User systemd services +```bash +# Create service file +mkdir -p ~/.config/systemd/user +cat > ~/.config/systemd/user/mybot.service << 'EOF' +[Unit] +Description=My bot + +[Service] +ExecStart=/home/YOURUSER/.bun/bin/bun run /home/YOURUSER/mybot/index.js +Restart=on-failure +RestartSec=5 + +[Install] +WantedBy=default.target +EOF + +# Enable and start +systemctl --user daemon-reload +systemctl --user enable --now mybot +systemctl --user status mybot +systemctl --user logs -f mybot +``` + +**Note:** User services stop when you log out unless lingering is enabled (ask admin). + +### 3. Process managers (pm2, etc.) +```bash +bun install -g pm2 +pm2 start bot.js --name mybot +pm2 save +``` + ## Getting Help ```bash