Skip to content

Hermes systemd 服务

本文整理了 3 个 systemd 服务配置:

  • hermes-webui.service
  • hermes-gateway.service
  • hermes-dashboard.service

WARNING

当前配置均以 root 用户运行,且部分服务监听 0.0.0.0。若机器暴露在公网,请务必配合防火墙、反向代理鉴权或内网访问策略,避免未授权访问。

1. Hermes Gateway

服务文件:/etc/systemd/system/hermes-gateway.service

ini
[Unit]
Description=Hermes Agent Gateway
After=network-online.target
Wants=network-online.target

[Service]
Type=simple
User=root
Group=root
WorkingDirectory=/root

ExecStart=hermes gateway

Restart=always
RestartSec=5

[Install]
WantedBy=multi-user.target

2. Hermes Dashboard

服务文件:/etc/systemd/system/hermes-dashboard.service

ini
[Unit]
Description=Hermes Agent Dashboard
After=network-online.target
Wants=network-online.target

[Service]
Type=simple
User=root
Group=root
WorkingDirectory=/root
ExecStart=hermes dashboard --host 0.0.0.0 --no-open --insecure

Restart=always
RestartSec=5

# 日志走 journalctl
StandardOutput=journal
StandardError=journal

[Install]
WantedBy=multi-user.target

3. Hermes WebUI

服务文件:/etc/systemd/system/hermes-webui.service

ini
[Unit]
Description=Hermes WebUI
After=network-online.target
Wants=network-online.target

[Service]
Type=forking
User=root
Group=root
WorkingDirectory=/root

Environment=HERMES_WEBUI_HOST=0.0.0.0
Environment=HERMES_WEBUI_PYTHON=/usr/local/lib/hermes-agent/venv/bin/python
Environment=HERMES_WEBUI_AGENT_DIR=/usr/local/lib/hermes-agent

ExecStart=/usr/local/lib/hermes-webui/ctl.sh start
ExecStop=/usr/local/lib/hermes-webui/ctl.sh stop
ExecReload=/usr/local/lib/hermes-webui/ctl.sh restart

PIDFile=/root/.hermes/webui.pid

Restart=on-failure
RestartSec=5

TimeoutStartSec=60
TimeoutStopSec=30

[Install]
WantedBy=multi-user.target

4. 生效与验证

4.1 重载并设置开机自启

bash
systemctl daemon-reload
systemctl enable --now hermes-webui.service
systemctl enable --now hermes-gateway.service
systemctl enable --now hermes-dashboard.service

4.2 查看状态

bash
systemctl status hermes-webui.service
systemctl status hermes-gateway.service
systemctl status hermes-dashboard.service

4.3 查看日志

bash
journalctl -u hermes-webui.service -f
journalctl -u hermes-gateway.service -f
journalctl -u hermes-dashboard.service -f