修正用户交易状态不正常显示问题
This commit is contained in:
parent
040473d4d3
commit
97ecf8e605
|
|
@ -19,7 +19,7 @@ import subprocess
|
|||
import sys
|
||||
from dataclasses import dataclass
|
||||
from pathlib import Path
|
||||
from typing import Optional, Tuple
|
||||
from typing import Optional, Tuple, List, Dict, Any
|
||||
|
||||
|
||||
DEFAULT_CANDIDATE_CONFS = [
|
||||
|
|
@ -29,6 +29,38 @@ DEFAULT_CANDIDATE_CONFS = [
|
|||
"/etc/supervisord.conf",
|
||||
]
|
||||
|
||||
# 常见 supervisorctl 路径候选
|
||||
DEFAULT_SUPERVISORCTL_CANDIDATES = [
|
||||
"/www/server/panel/pyenv/bin/supervisorctl",
|
||||
"/usr/bin/supervisorctl",
|
||||
"/usr/local/bin/supervisorctl",
|
||||
"/usr/local/python/bin/supervisorctl",
|
||||
]
|
||||
|
||||
def _detect_supervisorctl_path() -> str:
|
||||
"""
|
||||
探测 supervisorctl 可执行文件路径
|
||||
"""
|
||||
env_path = (os.getenv("SUPERVISORCTL_PATH") or "").strip()
|
||||
if env_path:
|
||||
return env_path
|
||||
|
||||
# 优先检查 PATH 中的 supervisorctl
|
||||
import shutil
|
||||
if shutil.which("supervisorctl"):
|
||||
return "supervisorctl"
|
||||
|
||||
# 检查常见绝对路径
|
||||
for p in DEFAULT_SUPERVISORCTL_CANDIDATES:
|
||||
try:
|
||||
if os.path.exists(p) and os.access(p, os.X_OK):
|
||||
return p
|
||||
except Exception:
|
||||
continue
|
||||
|
||||
return "supervisorctl" # 兜底
|
||||
|
||||
|
||||
# 常见 supervisord 主日志路径候选(不同发行版/面板插件差异很大)
|
||||
DEFAULT_SUPERVISORD_LOG_CANDIDATES = [
|
||||
# aaPanel / 宝塔 supervisor 插件常见
|
||||
|
|
@ -226,7 +258,7 @@ def write_program_ini(program_dir: Path, filename: str, content: str) -> Path:
|
|||
|
||||
|
||||
def _build_supervisorctl_cmd(args: list[str]) -> list[str]:
|
||||
supervisorctl_path = os.getenv("SUPERVISORCTL_PATH", "supervisorctl")
|
||||
supervisorctl_path = _detect_supervisorctl_path()
|
||||
supervisor_conf = (os.getenv("SUPERVISOR_CONF") or "").strip()
|
||||
use_sudo = (os.getenv("SUPERVISOR_USE_SUDO", "false") or "false").lower() == "true"
|
||||
|
||||
|
|
@ -250,8 +282,15 @@ def run_supervisorctl(args: list[str], timeout_sec: int = 10) -> str:
|
|||
res = subprocess.run(cmd, capture_output=True, text=True, timeout=int(timeout_sec))
|
||||
except subprocess.TimeoutExpired:
|
||||
raise RuntimeError("supervisorctl 超时")
|
||||
except FileNotFoundError:
|
||||
# 明确提示找不到命令,帮助排查路径问题
|
||||
cmd_str = " ".join(cmd)
|
||||
raise RuntimeError(f"Command not found: {cmd[0]} (Full cmd: {cmd_str})")
|
||||
except Exception as e:
|
||||
raise RuntimeError(f"supervisorctl execution failed: {str(e)}")
|
||||
|
||||
out = (res.stdout or "").strip()
|
||||
|
||||
err = (res.stderr or "").strip()
|
||||
combined = "\n".join([s for s in [out, err] if s]).strip()
|
||||
# supervisorctl: status 在存在 STOPPED 等进程时可能返回 exit=3,但输出仍然有效
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user