Commit 3e8496f6 authored by 郭阔's avatar 郭阔

fix: remove last hardcoded user, panel refresh loop

- sudo -u yichu replaced by NH_RUN_USER env (linux panels running as
  root configure the execution user; empty = current user, darwin
  always direct) — last hardcode outside guarded legacy tools
- logins.html: emit meta refresh only while a login test is running
  (content=0 caused an infinite reload loop)
- deploy/migrate keep their overridable yichu defaults (legacy server
  tools, already parameterized via args/env)
parent caf7cca6
...@@ -57,6 +57,10 @@ DIGEST_BUDGET_USD=2 ...@@ -57,6 +57,10 @@ DIGEST_BUDGET_USD=2
# Obsidian Vault 根目录;设置后会拒绝读取该目录之外的 archive_path # Obsidian Vault 根目录;设置后会拒绝读取该目录之外的 archive_path
# OBSIDIAN_VAULT_PATH=/home/yichu/Documents/Obsidian/MyVault # OBSIDIAN_VAULT_PATH=/home/yichu/Documents/Obsidian/MyVault
# === 面板执行用户(仅 Linux;macOS 忽略) ===
# 面板以 root 运行时,digest/续采命令切换到的用户;留空 = 直接以面板当前用户执行
# NH_RUN_USER=yichu
# === 技能仓库(login 预检与采集调用) === # === 技能仓库(login 预检与采集调用) ===
# SKILLS_DIR=/Users/you/news-hub-skills # SKILLS_DIR=/Users/you/news-hub-skills
# SKILLS_REPO_URL=https://git.example.com/news-hub-skills.git # setup.sh 自动 clone 用 # SKILLS_REPO_URL=https://git.example.com/news-hub-skills.git # setup.sh 自动 clone 用
...@@ -49,8 +49,11 @@ DIGEST_SCRIPT = str(WORK_DIR / "bin" / "daily-digest.sh") ...@@ -49,8 +49,11 @@ DIGEST_SCRIPT = str(WORK_DIR / "bin" / "daily-digest.sh")
# ── 平台适配 ────────────────────────────────────────────── # ── 平台适配 ──────────────────────────────────────────────
# macOS 上调度走 launchd(标签 com.newsharvester.<source>),无 systemctl/sudo -u。 # macOS 上调度走 launchd(标签 com.newsharvester.<source>),无 systemctl/sudo -u。
# NH_OS 环境变量可覆盖检测(与 platform.sh 同规则,测试模拟另一平台用)。 # NH_OS 环境变量可覆盖检测(与 platform.sh 同规则,测试模拟另一平台用)。
# NH_RUN_USER:Linux 上面板以 root 运行时切换到的执行用户(旧服务器为 yichu,
# 新部署在 web.conf / 服务 EnvironmentFile 里配置);留空 = 直接以当前用户执行。
IS_DARWIN = os.environ.get("NH_OS", "darwin" if sys.platform == "darwin" else "linux") == "darwin" IS_DARWIN = os.environ.get("NH_OS", "darwin" if sys.platform == "darwin" else "linux") == "darwin"
LAUNCHD_GUI = f"gui/{os.getuid()}" LAUNCHD_GUI = f"gui/{os.getuid()}"
RUN_USER = os.environ.get("NH_RUN_USER", "").strip()
# ── Flask 应用 ───────────────────────────────────────────── # ── Flask 应用 ─────────────────────────────────────────────
app = Flask(__name__) app = Flask(__name__)
...@@ -838,7 +841,7 @@ def run_digest(): ...@@ -838,7 +841,7 @@ def run_digest():
# 后台启动 daily-digest.sh(非阻塞) # 后台启动 daily-digest.sh(非阻塞)
# Linux 以 yichu 用户执行,确保文件权限/邮件/PATH 全部正确;macOS 直接当前用户 # Linux 以 yichu 用户执行,确保文件权限/邮件/PATH 全部正确;macOS 直接当前用户
digest_cmd = [DIGEST_SCRIPT] if IS_DARWIN else ["sudo", "-u", "yichu", DIGEST_SCRIPT] digest_cmd = [DIGEST_SCRIPT] if (IS_DARWIN or not RUN_USER) else ["sudo", "-u", RUN_USER, DIGEST_SCRIPT]
proc = subprocess.Popen( proc = subprocess.Popen(
digest_cmd, digest_cmd,
stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True,
...@@ -890,7 +893,7 @@ def continue_source(name): ...@@ -890,7 +893,7 @@ def continue_source(name):
# 后台启动 continue.sh(非阻塞) # 后台启动 continue.sh(非阻塞)
# Linux 以 yichu 用户执行(通过 sudo -u);macOS 直接以当前用户执行(继承面板环境) # Linux 以 yichu 用户执行(通过 sudo -u);macOS 直接以当前用户执行(继承面板环境)
cmd = ([CONTINUE_SCRIPT] if IS_DARWIN else ["sudo", "-u", "yichu", CONTINUE_SCRIPT]) \ cmd = ([CONTINUE_SCRIPT] if (IS_DARWIN or not RUN_USER) else ["sudo", "-u", RUN_USER, CONTINUE_SCRIPT]) \
+ [name, "--mode", mode, "--yes"] + [name, "--mode", mode, "--yes"]
if debug_flag: if debug_flag:
cmd.append("--debug") cmd.append("--debug")
......
{% extends "base.html" %} {% extends "base.html" %}
{% block title %}站点登录 — News Harvester{% endblock %} {% block title %}站点登录 — News Harvester{% endblock %}
{% block extra_head %} {% block extra_head %}
<meta http-equiv="refresh" content="{% if test_state and test_state.values() | selectattr('running') | list %}5{% else %}0{% endif %}"> {% if test_state and test_state.values() | selectattr('running') | list %}
<meta http-equiv="refresh" content="5">
{% endif %}
{% endblock %} {% endblock %}
{% block content %} {% block content %}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment