服务和程序目录改为由 root 运行。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-10-11 00:41:41 +08:00
parent a1c6ae02e9
commit fe530a619d
2 changed files with 14 additions and 4 deletions
+13 -3
View File
@@ -16,7 +16,7 @@ INSTALL_ROOT="${INSTALL_ROOT:-/opt/hypernode}"
DATA_DIR="${DATA_DIR:-/var/lib/hypernode}"
GIT_URL="${GIT_URL:-https://git.bz121.com/dekun/HyperNode-AI.git}"
GIT_BRANCH="${GIT_BRANCH:-main}"
APP_USER="hypernode"
APP_USER="root"
SERVICE_NAME="hypernode"
BIND_HOST="0.0.0.0"
BIND_PORT="33333"
@@ -108,6 +108,9 @@ install_packages() {
}
ensure_user() {
if [[ "${APP_USER}" == "root" ]]; then
return 0
fi
if ! id -u "${APP_USER}" >/dev/null 2>&1; then
useradd --system --home-dir "${INSTALL_ROOT}" --shell /usr/sbin/nologin "${APP_USER}"
fi
@@ -223,7 +226,11 @@ wait_until_ready() {
verify_app() {
log "检查程序能否启动"
if ! /usr/sbin/runuser -u "${APP_USER}" -- bash -c "cd '${INSTALL_ROOT}' && exec '${INSTALL_ROOT}/.venv/bin/python' -c 'import app.main'"; then
local runner=(bash -c "cd '${INSTALL_ROOT}' && exec '${INSTALL_ROOT}/.venv/bin/python' -c 'import app.main'")
if [[ "${APP_USER}" != "root" ]]; then
runner=(/usr/sbin/runuser -u "${APP_USER}" -- "${runner[@]}")
fi
if ! "${runner[@]}"; then
echo "程序导入失败,没有重启服务。请把上面的报错发出来。" >&2
return 1
fi
@@ -307,9 +314,12 @@ cmd_uninstall() {
echo "数据库已保留在 ${DATA_DIR}"
fi
if id -u "${APP_USER}" >/dev/null 2>&1; then
if [[ "${APP_USER}" != "root" ]] && id -u "${APP_USER}" >/dev/null 2>&1; then
userdel "${APP_USER}" || echo "系统用户 ${APP_USER} 未删除,可稍后执行 userdel ${APP_USER}"
fi
if id -u hypernode >/dev/null 2>&1; then
userdel hypernode >/dev/null 2>&1 || true
fi
log "卸载完成"
}
+1 -1
View File
@@ -67,7 +67,7 @@ curl http://127.0.0.1:33333/health
手动补跑某一天的清算:
```bash
sudo -u hypernode /opt/hypernode/.venv/bin/python -m app.settle --date 2026-10-09
/opt/hypernode/.venv/bin/python -m app.settle --date 2026-10-09
```
不带日期时,结算上一个已经结束的 UTC 账本日。服务正常运行时,北京时间每天 00:05 会自动执行。