fix: persist detail enhancement during deploy
这个提交存在于:
父节点
d8a5c181cd
当前提交
c3d7151f86
共有 4 个文件被更改,包括 28 次插入 和 4 次删除
|
|
@ -175,6 +175,6 @@
|
|||
- Type: feature behavior / deployment / testing.
|
||||
- Symptom: schema, runtime fallback, and VM persisted config could independently retain `enable_detail_enhancement=False`; the Bash deploy script depended on an SSH alias and `pytest`.
|
||||
- Root cause: new-install defaults and existing persistent overrides are separate paths; the script assumed a Unix developer environment.
|
||||
- Fix or workaround: set all three defaults to `true`; deploy updates the VM JSON config; Bash accepts `VM`, `SSH_KEY`, `SSH_PORT`, `PYTHON_BIN`, and `SKIP_LOCAL_TESTS`; add `ops/deploy-plugin.ps1`.
|
||||
- Fix or workaround: set all three defaults to `true`; after stopping AstrBot, deploy writes the VM JSON config before startup; Bash accepts `VM`, `SSH_KEY`, `SSH_PORT`, `PYTHON_BIN`, `SKIP_LOCAL_TESTS`, and `DETAIL_ENHANCEMENT_ENABLED`; add `ops/deploy-plugin.ps1`.
|
||||
- Prevention rule: configuration switches must be checked at schema, runtime fallback, and production persistence layers; cross-machine deploy commands must make SSH and test-runtime dependencies explicit.
|
||||
- Validation evidence: `tests/test_d1_default_enabled.py` and `tests/test_deploy_script_windows.py`; deployment verifies service state, logs, and persisted config.
|
||||
|
|
@ -13,7 +13,8 @@ param(
|
|||
[int]$SshPort = 22,
|
||||
[string]$SshKey = (Join-Path $env:USERPROFILE ".codex\ssh\astrbot_vm_ed25519"),
|
||||
[string]$PythonBin = "C:\Users\Administrator\.cache\codex-runtimes\codex-primary-runtime\dependencies\python\python.exe",
|
||||
[switch]$SkipLocalTests
|
||||
[switch]$SkipLocalTests,
|
||||
[switch]$EnableDetailEnhancement
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
|
@ -40,6 +41,7 @@ $env:SSH_PORT = "$SshPort"
|
|||
$env:SSH_KEY = Convert-ToGitBashPath $SshKey
|
||||
$env:PYTHON_BIN = if ($SkipLocalTests) { "python" } else { Convert-ToGitBashPath $PythonBin }
|
||||
$env:SKIP_LOCAL_TESTS = if ($SkipLocalTests) { "1" } else { "0" }
|
||||
$env:DETAIL_ENHANCEMENT_ENABLED = if ($EnableDetailEnhancement) { "1" } else { "" }
|
||||
|
||||
$script = Join-Path $PSScriptRoot "deploy-plugin.sh"
|
||||
& $bash $script $Target @Files
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ SSH_KEY="${SSH_KEY:-}"
|
|||
SSH_PORT="${SSH_PORT:-22}"
|
||||
PYTHON_BIN="${PYTHON_BIN:-python}"
|
||||
SKIP_LOCAL_TESTS="${SKIP_LOCAL_TESTS:-0}"
|
||||
DETAIL_ENHANCEMENT_ENABLED="${DETAIL_ENHANCEMENT_ENABLED:-}"
|
||||
SSH_OPTS=(-o BatchMode=yes -p "$SSH_PORT")
|
||||
SCP_OPTS=(-o BatchMode=yes -P "$SSH_PORT")
|
||||
if [ -n "$SSH_KEY" ]; then
|
||||
|
|
@ -132,6 +133,26 @@ if [ "$TARGET" = companion ] || [ "$TARGET" = both ]; then
|
|||
fi
|
||||
|
||||
echo "==> 启动"
|
||||
# Apply explicit plugin configuration only after AstrBot has stopped: otherwise
|
||||
# its shutdown persistence can overwrite the staged value with stale memory.
|
||||
if [ -n "$DETAIL_ENHANCEMENT_ENABLED" ] && { [ "$TARGET" = companion ] || [ "$TARGET" = both ]; }; then
|
||||
echo "==> Applying DETAIL_ENHANCEMENT_ENABLED=$DETAIL_ENHANCEMENT_ENABLED"
|
||||
cat <<'PY' | ssh "${SSH_OPTS[@]}" "$VM" "sudo '$PY' - '$DETAIL_ENHANCEMENT_ENABLED'"
|
||||
import codecs
|
||||
import json
|
||||
import sys
|
||||
|
||||
path = "/var/lib/astrbot/data/config/astrbot_plugin_private_companion_ops_config.json"
|
||||
value = sys.argv[1].strip().lower() in ("1", "true", "yes", "on")
|
||||
with codecs.open(path, "r", "utf-8-sig") as handle:
|
||||
config = json.load(handle)
|
||||
config["enable_detail_enhancement"] = value
|
||||
with codecs.open(path, "w", "utf-8-sig") as handle:
|
||||
json.dump(config, handle, ensure_ascii=False, indent=2)
|
||||
handle.write("\n")
|
||||
print("enable_detail_enhancement=" + str(value))
|
||||
PY
|
||||
fi
|
||||
ssh "${SSH_OPTS[@]}" "$VM" "sudo systemctl start astrbot"
|
||||
sleep 60
|
||||
|
||||
|
|
|
|||
|
|
@ -11,13 +11,14 @@ ROOT = pathlib.Path(__file__).resolve().parents[1]
|
|||
class WindowsDeployEntrypointTests(unittest.TestCase):
|
||||
def test_bash_script_accepts_explicit_connection_and_test_settings(self):
|
||||
script = (ROOT / "ops" / "deploy-plugin.sh").read_text(encoding="utf-8")
|
||||
for token in ("SSH_KEY=", "SSH_PORT=", "PYTHON_BIN=", "SKIP_LOCAL_TESTS=", "SCP_OPTS="):
|
||||
for token in ("SSH_KEY=", "SSH_PORT=", "PYTHON_BIN=", "SKIP_LOCAL_TESTS=", "DETAIL_ENHANCEMENT_ENABLED=", "SCP_OPTS="):
|
||||
self.assertIn(token, script)
|
||||
self.assertIn('"$PYTHON_BIN" -m unittest discover -s tests -q', script)
|
||||
self.assertIn("shutdown persistence", script)
|
||||
|
||||
def test_powershell_wrapper_supplies_vm_key_and_python(self):
|
||||
wrapper = (ROOT / "ops" / "deploy-plugin.ps1").read_text(encoding="utf-8")
|
||||
for token in ("VmHost = \"192.168.31.215\"", "VmUser = \"agent\"", "SshKey", "PythonBin", "SSH_KEY", "PYTHON_BIN"):
|
||||
for token in ("VmHost = \"192.168.31.215\"", "VmUser = \"agent\"", "SshKey", "PythonBin", "SSH_KEY", "PYTHON_BIN", "EnableDetailEnhancement", "DETAIL_ENHANCEMENT_ENABLED"):
|
||||
self.assertIn(token, wrapper)
|
||||
|
||||
|
||||
|
|
|
|||
正在加载…
添加表格
在新工单中引用