修改
This commit is contained in:
1 parent
0c740f5a53
commit
a1867fd03e
5 files changed
+26
-12
No files matched your search
@@ -46,9 +46,11 @@ python -m maintain
|
|||||||
### 3) 必填配置(配置编辑页)
|
### 3) 必填配置(配置编辑页)
|
||||||
|
|
||||||
- `cliproxy_management_base`、`cliproxy_management_key`:巡检/清理必填。
|
- `cliproxy_management_base`、`cliproxy_management_key`:巡检/清理必填。
|
||||||
- `codex_stats_oauth_dir`:若 JSON 不在项目内 `accounts/oauth`,必须填真实目录(如 `~/.cli-proxy-api`)。
|
- **CPA auths 固定目录**:部署时在仓库里改 `maintain/paths_config.py` 的 `CPA_AUTHS_DIR`(例如 NAS 挂载点 `/mnt/cpa_auths`)。新库默认会把 **`codex_stats_oauth_dir`** 与流水线 **`cpa_target_dir`** 设成该路径;**统计目录留空**时也会回落到该路径。已有 SQLite 里若仍是旧值,可在「配置编辑」里改一次或删掉对应 `settings` 行后重启。
|
||||||
- `cliproxy_sweeper_threshold` / `cliproxy_sweeper_run_mode`:控制 `/usage` 清理阈值与 delete/observe 模式。
|
- `cliproxy_sweeper_threshold` / `cliproxy_sweeper_run_mode`:控制 `/usage` 清理阈值与 delete/observe 模式。
|
||||||
|
|
||||||
|
说明:注册仍先写到项目内 `accounts/oauth`;流水线「迁出」会把 JSON **移动**到 `cpa_target_dir`(即上述挂载目录)。若你希望统计/巡检直接扫 NAS,保持 `codex_stats_oauth_dir` 与挂载目录一致即可。
|
||||||
|
|
||||||
### 临时邮箱(mail.chatgpt.org.uk)
|
### 临时邮箱(mail.chatgpt.org.uk)
|
||||||
|
|
||||||
- **`MAIL_API_KEY`** 或 **`EMAIL_API_KEY`**:调用 `https://mail.chatgpt.org.uk/api` 时放在请求头 **`X-API-Key`**(默认占位 `gpt-test`,生产请改成你自己的 key)。
|
- **`MAIL_API_KEY`** 或 **`EMAIL_API_KEY`**:调用 `https://mail.chatgpt.org.uk/api` 时放在请求头 **`X-API-Key`**(默认占位 `gpt-test`,生产请改成你自己的 key)。
|
||||||
|
|||||||
+1
-1
@@ -1029,7 +1029,7 @@ def _before():
|
|||||||
|
|
||||||
def main() -> None:
|
def main() -> None:
|
||||||
db.init_db()
|
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"))
|
port = int(os.environ.get("CODEX_MAINTAIN_PORT", "8765"))
|
||||||
print(
|
print(
|
||||||
f"Codex 维护台 http://{host}:{port} "
|
f"Codex 维护台 http://{host}:{port} "
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ from urllib.parse import quote_plus
|
|||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
|
from maintain.paths_config import CPA_AUTHS_DIR
|
||||||
|
|
||||||
REPO_ROOT = Path(__file__).resolve().parent.parent
|
REPO_ROOT = Path(__file__).resolve().parent.parent
|
||||||
|
|
||||||
logger = logging.getLogger("cpa-runner")
|
logger = logging.getLogger("cpa-runner")
|
||||||
@@ -84,7 +86,7 @@ def runner_config_from_env() -> RunnerConfig:
|
|||||||
target_dir=Path(
|
target_dir=Path(
|
||||||
os.getenv(
|
os.getenv(
|
||||||
"TARGET_DIR",
|
"TARGET_DIR",
|
||||||
str(REPO_ROOT / "export" / "cpa_auths"),
|
CPA_AUTHS_DIR,
|
||||||
)
|
)
|
||||||
).resolve(),
|
).resolve(),
|
||||||
python_bin=os.getenv("PYTHON_BIN", "python3"),
|
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(
|
oauth_dir=Path(
|
||||||
g("pipeline_oauth_dir", str(REPO_ROOT / "accounts" / "oauth"))
|
g("pipeline_oauth_dir", str(REPO_ROOT / "accounts" / "oauth"))
|
||||||
).resolve(),
|
).resolve(),
|
||||||
target_dir=Path(
|
target_dir=Path(g("cpa_target_dir", CPA_AUTHS_DIR)).resolve(),
|
||||||
g("cpa_target_dir", str(REPO_ROOT / "export" / "cpa_auths"))
|
|
||||||
).resolve(),
|
|
||||||
python_bin=g("pipeline_python_bin", "python3"),
|
python_bin=g("pipeline_python_bin", "python3"),
|
||||||
dingtalk_webhook=g("dingtalk_webhook", "").strip(),
|
dingtalk_webhook=g("dingtalk_webhook", "").strip(),
|
||||||
dingtalk_secret=g("dingtalk_secret", "").strip(),
|
dingtalk_secret=g("dingtalk_secret", "").strip(),
|
||||||
|
|||||||
+9
-6
@@ -8,6 +8,8 @@ from datetime import datetime, timezone
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Any, Optional
|
from typing import Any, Optional
|
||||||
|
|
||||||
|
from maintain.paths_config import CPA_AUTHS_DIR
|
||||||
|
|
||||||
ROOT = Path(__file__).resolve().parent.parent
|
ROOT = Path(__file__).resolve().parent.parent
|
||||||
DB_PATH = ROOT / "maintain" / "data" / "maintain.db"
|
DB_PATH = ROOT / "maintain" / "data" / "maintain.db"
|
||||||
ACCOUNTS_OAUTH = ROOT / "accounts" / "oauth"
|
ACCOUNTS_OAUTH = ROOT / "accounts" / "oauth"
|
||||||
@@ -18,11 +20,12 @@ _lock = threading.Lock()
|
|||||||
def resolve_oauth_stats_dir() -> Path:
|
def resolve_oauth_stats_dir() -> Path:
|
||||||
"""
|
"""
|
||||||
统计 / 巡检用的 codex JSON 目录。
|
统计 / 巡检用的 codex JSON 目录。
|
||||||
留空 = 项目内 accounts/oauth;若注册成功后文件迁入 Cliproxy auth 目录,填该目录绝对路径。
|
配置留空时使用 maintain/paths_config.CPA_AUTHS_DIR(部署时写死挂载点)。
|
||||||
|
若需退回项目内目录,在「配置编辑」显式填项目 accounts/oauth 绝对路径。
|
||||||
"""
|
"""
|
||||||
raw = get_setting("codex_stats_oauth_dir", "").strip()
|
raw = get_setting("codex_stats_oauth_dir", "").strip()
|
||||||
if not raw:
|
if not raw:
|
||||||
return ACCOUNTS_OAUTH.resolve()
|
return Path(CPA_AUTHS_DIR).expanduser().resolve()
|
||||||
return Path(raw).expanduser().resolve()
|
return Path(raw).expanduser().resolve()
|
||||||
|
|
||||||
|
|
||||||
@@ -92,7 +95,7 @@ def init_db() -> None:
|
|||||||
if cur.fetchone()[0] == 0:
|
if cur.fetchone()[0] == 0:
|
||||||
c.execute(
|
c.execute(
|
||||||
"INSERT INTO cpa (name, code, target_count, api_base_url) VALUES (?,?,?,?)",
|
"INSERT INTO cpa (name, code, target_count, api_base_url) VALUES (?,?,?,?)",
|
||||||
("账号池", "default", 8000, ""),
|
("账号池", "default", 500, ""),
|
||||||
)
|
)
|
||||||
defaults = {
|
defaults = {
|
||||||
"auto_inspect_enabled": "0",
|
"auto_inspect_enabled": "0",
|
||||||
@@ -107,7 +110,7 @@ def init_db() -> None:
|
|||||||
"pipeline_interval_min": "10",
|
"pipeline_interval_min": "10",
|
||||||
"pipeline_run_script": str(ROOT / "run.py"),
|
"pipeline_run_script": str(ROOT / "run.py"),
|
||||||
"pipeline_oauth_dir": str(ROOT / "accounts" / "oauth"),
|
"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",
|
"pipeline_python_bin": "python3",
|
||||||
"run_subprocess_timeout_sec": "480",
|
"run_subprocess_timeout_sec": "480",
|
||||||
"cpa_exit_on_empty": "0",
|
"cpa_exit_on_empty": "0",
|
||||||
@@ -120,8 +123,8 @@ def init_db() -> None:
|
|||||||
"cliproxy_sweeper_threshold": "3",
|
"cliproxy_sweeper_threshold": "3",
|
||||||
"cliproxy_sweeper_run_mode": "delete",
|
"cliproxy_sweeper_run_mode": "delete",
|
||||||
"cliproxy_sweeper_allow_name_fallback": "1",
|
"cliproxy_sweeper_allow_name_fallback": "1",
|
||||||
# 成功后 JSON 若在 Cliproxy auth 目录,填绝对路径;留空则用项目 accounts/oauth
|
# 与 paths_config.CPA_AUTHS_DIR 一致;可在 Web 里改
|
||||||
"codex_stats_oauth_dir": "",
|
"codex_stats_oauth_dir": CPA_AUTHS_DIR,
|
||||||
"inspect_probe_valid_json": "",
|
"inspect_probe_valid_json": "",
|
||||||
"pipeline_state_file": str(ROOT / "maintain" / "data" / "pipeline_state.json"),
|
"pipeline_state_file": str(ROOT / "maintain" / "data" / "pipeline_state.json"),
|
||||||
"pipeline_log_file": str(ROOT / "maintain" / "data" / "pipeline.log"),
|
"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