docs: add persistent services section to SERVER.md
Documents tmux, user systemd, and pm2 options for running long-lived processes. Notes lingering requirement for systemd.
This commit is contained in:
parent
3c8f961cdc
commit
2887ad4122
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue