Merge pull request #23 from living-ip/codex/avoid-starting-legacy-teleo-leo-20260626
Some checks failed
CI / lint-and-test (push) Has been cancelled
Some checks failed
CI / lint-and-test (push) Has been cancelled
Avoid starting inactive legacy Leo bot on deploy
This commit is contained in:
commit
19f5346118
3 changed files with 19 additions and 3 deletions
|
|
@ -112,19 +112,25 @@ add_restart_if_unit_exists() {
|
||||||
add_restart "$1"
|
add_restart "$1"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
add_restart_if_unit_active() {
|
||||||
|
if systemctl is-active --quiet "$1.service"; then
|
||||||
|
add_restart "$1"
|
||||||
|
fi
|
||||||
|
}
|
||||||
if [ "$OLD_SHA" != "none" ]; then
|
if [ "$OLD_SHA" != "none" ]; then
|
||||||
if git diff --name-only "$OLD_SHA" "$NEW_SHA" -- lib/ teleo-pipeline.py reweave.py telegram/ 2>/dev/null | grep -q '\.py$'; then
|
if git diff --name-only "$OLD_SHA" "$NEW_SHA" -- lib/ teleo-pipeline.py reweave.py telegram/ 2>/dev/null | grep -q '\.py$'; then
|
||||||
add_restart teleo-pipeline
|
add_restart teleo-pipeline
|
||||||
fi
|
fi
|
||||||
if git diff --name-only "$OLD_SHA" "$NEW_SHA" -- telegram/ 2>/dev/null | grep -q '\.py$'; then
|
if git diff --name-only "$OLD_SHA" "$NEW_SHA" -- telegram/ 2>/dev/null | grep -q '\.py$'; then
|
||||||
add_restart teleo-agent@leo
|
add_restart_if_unit_active teleo-agent@leo
|
||||||
add_restart_if_unit_exists teleo-agent@leo-wallet-test
|
add_restart_if_unit_exists teleo-agent@leo-wallet-test
|
||||||
fi
|
fi
|
||||||
if git diff --name-only "$OLD_SHA" "$NEW_SHA" -- diagnostics/ 2>/dev/null | grep -q '\.py$'; then
|
if git diff --name-only "$OLD_SHA" "$NEW_SHA" -- diagnostics/ 2>/dev/null | grep -q '\.py$'; then
|
||||||
add_restart teleo-diagnostics
|
add_restart teleo-diagnostics
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
RESTART="teleo-pipeline teleo-diagnostics teleo-agent@leo"
|
RESTART="teleo-pipeline teleo-diagnostics"
|
||||||
|
add_restart_if_unit_active teleo-agent@leo
|
||||||
add_restart_if_unit_exists teleo-agent@leo-wallet-test
|
add_restart_if_unit_exists teleo-agent@leo-wallet-test
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -104,6 +104,6 @@ echo "Deploy complete."
|
||||||
if $RESTART; then
|
if $RESTART; then
|
||||||
echo ""
|
echo ""
|
||||||
echo "=== Restarting services ==="
|
echo "=== Restarting services ==="
|
||||||
ssh "$VPS_HOST" "sudo systemctl restart teleo-pipeline teleo-diagnostics teleo-agent@leo; if systemctl list-units --all --full teleo-agent@leo-wallet-test.service --no-legend | grep -q .; then sudo systemctl restart teleo-agent@leo-wallet-test; fi"
|
ssh "$VPS_HOST" "sudo systemctl restart teleo-pipeline teleo-diagnostics; if systemctl is-active --quiet teleo-agent@leo.service; then sudo systemctl restart teleo-agent@leo; fi; if systemctl list-units --all --full teleo-agent@leo-wallet-test.service --no-legend | grep -q .; then sudo systemctl restart teleo-agent@leo-wallet-test; fi"
|
||||||
echo "Services restarted."
|
echo "Services restarted."
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,16 @@ def test_deploy_scripts_restart_wallet_test_agent_when_present():
|
||||||
assert "teleo-agent@leo-wallet-test" in manual_deploy
|
assert "teleo-agent@leo-wallet-test" in manual_deploy
|
||||||
|
|
||||||
|
|
||||||
|
def test_deploy_scripts_do_not_start_inactive_legacy_leo_agent():
|
||||||
|
auto_deploy = (REPO_ROOT / "deploy" / "auto-deploy.sh").read_text()
|
||||||
|
manual_deploy = (REPO_ROOT / "deploy" / "deploy.sh").read_text()
|
||||||
|
|
||||||
|
assert "add_restart_if_unit_active teleo-agent@leo" in auto_deploy
|
||||||
|
assert "add_restart teleo-agent@leo" not in auto_deploy
|
||||||
|
assert "systemctl is-active --quiet teleo-agent@leo.service" in manual_deploy
|
||||||
|
assert "teleo-pipeline teleo-diagnostics teleo-agent@leo" not in manual_deploy
|
||||||
|
|
||||||
|
|
||||||
def test_auto_deploy_prefers_github_remote_when_present():
|
def test_auto_deploy_prefers_github_remote_when_present():
|
||||||
auto_deploy = (REPO_ROOT / "deploy" / "auto-deploy.sh").read_text()
|
auto_deploy = (REPO_ROOT / "deploy" / "auto-deploy.sh").read_text()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue