Merge PR #968: docs: add systemd user service instructions to README
This commit is contained in:
53
README.md
53
README.md
@@ -865,6 +865,59 @@ docker run -v ~/.nanobot:/root/.nanobot --rm nanobot agent -m "Hello!"
|
|||||||
docker run -v ~/.nanobot:/root/.nanobot --rm nanobot status
|
docker run -v ~/.nanobot:/root/.nanobot --rm nanobot status
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## 🐧 Linux Service
|
||||||
|
|
||||||
|
Run the gateway as a systemd user service so it starts automatically and restarts on failure.
|
||||||
|
|
||||||
|
**1. Find the nanobot binary path:**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
which nanobot # e.g. /home/user/.local/bin/nanobot
|
||||||
|
```
|
||||||
|
|
||||||
|
**2. Create the service file** at `~/.config/systemd/user/nanobot-gateway.service` (replace `ExecStart` path if needed):
|
||||||
|
|
||||||
|
```ini
|
||||||
|
[Unit]
|
||||||
|
Description=Nanobot Gateway
|
||||||
|
After=network.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
ExecStart=%h/.local/bin/nanobot gateway
|
||||||
|
Restart=always
|
||||||
|
RestartSec=10
|
||||||
|
NoNewPrivileges=yes
|
||||||
|
ProtectSystem=strict
|
||||||
|
ReadWritePaths=%h
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=default.target
|
||||||
|
```
|
||||||
|
|
||||||
|
**3. Enable and start:**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
systemctl --user daemon-reload
|
||||||
|
systemctl --user enable --now nanobot-gateway
|
||||||
|
```
|
||||||
|
|
||||||
|
**Common operations:**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
systemctl --user status nanobot-gateway # check status
|
||||||
|
systemctl --user restart nanobot-gateway # restart after config changes
|
||||||
|
journalctl --user -u nanobot-gateway -f # follow logs
|
||||||
|
```
|
||||||
|
|
||||||
|
If you edit the `.service` file itself, run `systemctl --user daemon-reload` before restarting.
|
||||||
|
|
||||||
|
> **Note:** User services only run while you are logged in. To keep the gateway running after logout, enable lingering:
|
||||||
|
>
|
||||||
|
> ```bash
|
||||||
|
> loginctl enable-linger $USER
|
||||||
|
> ```
|
||||||
|
|
||||||
## 📁 Project Structure
|
## 📁 Project Structure
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|||||||
Reference in New Issue
Block a user