修改
This commit is contained in:
1 parent
0c740f5a53
commit
a1867fd03e
5 files changed
+26
-12
No files matched your search
+1
-1
@@ -1029,7 +1029,7 @@ def _before():
|
||||
|
||||
def main() -> None:
|
||||
db.init_db()
|
||||
host = os.environ.get("CODEX_MAINTAIN_HOST", "127.0.0.1")
|
||||
host = os.environ.get("CODEX_MAINTAIN_HOST", "0.0.0.0")
|
||||
port = int(os.environ.get("CODEX_MAINTAIN_PORT", "8765"))
|
||||
print(
|
||||
f"Codex 维护台 http://{host}:{port} "
|
||||
|
||||
@@ -23,6 +23,8 @@ from urllib.parse import quote_plus
|
||||
|
||||
import requests
|
||||
|
||||
from maintain.paths_config import CPA_AUTHS_DIR
|
||||
|
||||
REPO_ROOT = Path(__file__).resolve().parent.parent
|
||||
|
||||
logger = logging.getLogger("cpa-runner")
|
||||
@@ -84,7 +86,7 @@ def runner_config_from_env() -> RunnerConfig:
|
||||
target_dir=Path(
|
||||
os.getenv(
|
||||
"TARGET_DIR",
|
||||
str(REPO_ROOT / "export" / "cpa_auths"),
|
||||
CPA_AUTHS_DIR,
|
||||
)
|
||||
).resolve(),
|
||||
python_bin=os.getenv("PYTHON_BIN", "python3"),
|
||||
@@ -424,9 +426,7 @@ def runner_config_from_db(get_setting: Callable[[str, str], str]) -> RunnerConfi
|
||||
oauth_dir=Path(
|
||||
g("pipeline_oauth_dir", str(REPO_ROOT / "accounts" / "oauth"))
|
||||
).resolve(),
|
||||
target_dir=Path(
|
||||
g("cpa_target_dir", str(REPO_ROOT / "export" / "cpa_auths"))
|
||||
).resolve(),
|
||||
target_dir=Path(g("cpa_target_dir", CPA_AUTHS_DIR)).resolve(),
|
||||
python_bin=g("pipeline_python_bin", "python3"),
|
||||
dingtalk_webhook=g("dingtalk_webhook", "").strip(),
|
||||
dingtalk_secret=g("dingtalk_secret", "").strip(),
|
||||
|
||||
+9
-6
@@ -8,6 +8,8 @@ from datetime import datetime, timezone
|
||||
from pathlib import Path
|
||||
from typing import Any, Optional
|
||||
|
||||
from maintain.paths_config import CPA_AUTHS_DIR
|
||||
|
||||
ROOT = Path(__file__).resolve().parent.parent
|
||||
DB_PATH = ROOT / "maintain" / "data" / "maintain.db"
|
||||
ACCOUNTS_OAUTH = ROOT / "accounts" / "oauth"
|
||||
@@ -18,11 +20,12 @@ _lock = threading.Lock()
|
||||
def resolve_oauth_stats_dir() -> Path:
|
||||
"""
|
||||
统计 / 巡检用的 codex JSON 目录。
|
||||
留空 = 项目内 accounts/oauth;若注册成功后文件迁入 Cliproxy auth 目录,填该目录绝对路径。
|
||||
配置留空时使用 maintain/paths_config.CPA_AUTHS_DIR(部署时写死挂载点)。
|
||||
若需退回项目内目录,在「配置编辑」显式填项目 accounts/oauth 绝对路径。
|
||||
"""
|
||||
raw = get_setting("codex_stats_oauth_dir", "").strip()
|
||||
if not raw:
|
||||
return ACCOUNTS_OAUTH.resolve()
|
||||
return Path(CPA_AUTHS_DIR).expanduser().resolve()
|
||||
return Path(raw).expanduser().resolve()
|
||||
|
||||
|
||||
@@ -92,7 +95,7 @@ def init_db() -> None:
|
||||
if cur.fetchone()[0] == 0:
|
||||
c.execute(
|
||||
"INSERT INTO cpa (name, code, target_count, api_base_url) VALUES (?,?,?,?)",
|
||||
("账号池", "default", 8000, ""),
|
||||
("账号池", "default", 500, ""),
|
||||
)
|
||||
defaults = {
|
||||
"auto_inspect_enabled": "0",
|
||||
@@ -107,7 +110,7 @@ def init_db() -> None:
|
||||
"pipeline_interval_min": "10",
|
||||
"pipeline_run_script": str(ROOT / "run.py"),
|
||||
"pipeline_oauth_dir": str(ROOT / "accounts" / "oauth"),
|
||||
"cpa_target_dir": str(ROOT / "export" / "cpa_auths"),
|
||||
"cpa_target_dir": CPA_AUTHS_DIR,
|
||||
"pipeline_python_bin": "python3",
|
||||
"run_subprocess_timeout_sec": "480",
|
||||
"cpa_exit_on_empty": "0",
|
||||
@@ -120,8 +123,8 @@ def init_db() -> None:
|
||||
"cliproxy_sweeper_threshold": "3",
|
||||
"cliproxy_sweeper_run_mode": "delete",
|
||||
"cliproxy_sweeper_allow_name_fallback": "1",
|
||||
# 成功后 JSON 若在 Cliproxy auth 目录,填绝对路径;留空则用项目 accounts/oauth
|
||||
"codex_stats_oauth_dir": "",
|
||||
# 与 paths_config.CPA_AUTHS_DIR 一致;可在 Web 里改
|
||||
"codex_stats_oauth_dir": CPA_AUTHS_DIR,
|
||||
"inspect_probe_valid_json": "",
|
||||
"pipeline_state_file": str(ROOT / "maintain" / "data" / "pipeline_state.json"),
|
||||
"pipeline_log_file": str(ROOT / "maintain" / "data" / "pipeline.log"),
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
"""部署侧固定路径:改这一处即可。
|
||||
|
||||
NAS / SMB 请先挂载到本机目录(例如 /mnt/cpa_auths),此处填挂载后的绝对路径。
|
||||
勿填 smb:// URL。
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
# 例如: sudo mount -t cifs //192.168.1.10/share/auths /mnt/nas-share/cpaauths
|
||||
CPA_AUTHS_DIR = "/mnt/nas-share/cpaauths"
|
||||
Reference in new issue
Block a user