diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f6a3701..de7c33f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -364,7 +364,7 @@ jobs: sudo bash ./scripts/ensure_host_swap.sh sudo bash ./scripts/install_2fa_bot_watcher.sh sudo bash ./scripts/recover_ib_gateway_ready.sh '${IB_GATEWAY_MODE}' - sudo bash ./scripts/install_gateway_health_watcher.sh + sudo bash ./scripts/install_gateway_health_watcher.sh '${IB_GATEWAY_MODE}' sudo docker compose ps sudo systemctl status ibkr-2fa-bot.timer --no-pager sudo systemctl status ibkr-gateway-healthcheck.timer --no-pager @@ -385,7 +385,7 @@ jobs: sudo bash ./scripts/install_2fa_bot_watcher.sh sudo bash ./scripts/recover_ib_gateway_ready.sh '${IB_GATEWAY_MODE}' - sudo bash ./scripts/install_gateway_health_watcher.sh + sudo bash ./scripts/install_gateway_health_watcher.sh '${IB_GATEWAY_MODE}' sudo docker compose ps sudo systemctl status ibkr-2fa-bot.timer --no-pager sudo systemctl status ibkr-gateway-healthcheck.timer --no-pager diff --git a/.github/workflows/remote-maintenance.yml b/.github/workflows/remote-maintenance.yml index f49bdbb..2f19c24 100644 --- a/.github/workflows/remote-maintenance.yml +++ b/.github/workflows/remote-maintenance.yml @@ -138,7 +138,7 @@ jobs: sudo docker compose up -d --no-build ib-gateway sudo bash ./scripts/install_2fa_bot_watcher.sh sudo bash ./scripts/recover_ib_gateway_ready.sh __IB_GATEWAY_MODE__ - sudo bash ./scripts/install_gateway_health_watcher.sh + sudo bash ./scripts/install_gateway_health_watcher.sh __IB_GATEWAY_MODE__ sudo docker compose ps EOF ) diff --git a/scripts/install_gateway_health_watcher.sh b/scripts/install_gateway_health_watcher.sh index 0774aba..d8d4246 100755 --- a/scripts/install_gateway_health_watcher.sh +++ b/scripts/install_gateway_health_watcher.sh @@ -6,7 +6,8 @@ repo_dir="${REPO_DIR:-$(cd "${script_dir}/.." && pwd)}" systemd_dir="${SYSTEMD_DIR:-/etc/systemd/system}" systemctl_bin="${SYSTEMCTL_BIN:-systemctl}" container_name="${CONTAINER_NAME:-${IB_GATEWAY_CONTAINER_NAME:-ib-gateway}}" -gateway_mode="${IB_GATEWAY_MODE:-paper}" +gateway_mode="${1:-${IB_GATEWAY_MODE:-paper}}" +compose_file="${COMPOSE_FILE:-docker-compose.yml}" health_interval_seconds="${IB_GATEWAY_HEALTHCHECK_INTERVAL_SECONDS:-300}" daily_restart_calendar="${IB_GATEWAY_DAILY_RESTART_ON_CALENDAR:-*-*-* 10:30:00 UTC}" @@ -23,6 +24,7 @@ Type=oneshot WorkingDirectory=$repo_dir Environment=IB_GATEWAY_CONTAINER_NAME=$container_name Environment=IB_GATEWAY_MODE=$gateway_mode +Environment=COMPOSE_FILE=$compose_file Environment=IB_GATEWAY_RECOVERY_LOCK_WAIT_SECONDS=0 ExecStart=/bin/bash -lc 'cd "$repo_dir" && exec ./scripts/recover_ib_gateway_ready.sh "$gateway_mode"' EOF @@ -51,6 +53,7 @@ Type=oneshot WorkingDirectory=$repo_dir Environment=IB_GATEWAY_CONTAINER_NAME=$container_name Environment=IB_GATEWAY_MODE=$gateway_mode +Environment=COMPOSE_FILE=$compose_file ExecStart=/bin/bash -lc 'cd "$repo_dir" && exec ./scripts/restart_ib_gateway_daily.sh "$gateway_mode"' EOF diff --git a/tests/test_gateway_recovery_scripts.sh b/tests/test_gateway_recovery_scripts.sh index 31975a3..3362981 100644 --- a/tests/test_gateway_recovery_scripts.sh +++ b/tests/test_gateway_recovery_scripts.sh @@ -45,6 +45,9 @@ grep -Fq 'ibkr-gateway-daily-restart.service' "$health_watcher_script" grep -Fq 'ibkr-gateway-daily-restart.timer' "$health_watcher_script" grep -Fq 'IB_GATEWAY_HEALTHCHECK_INTERVAL_SECONDS:-300' "$health_watcher_script" grep -Fq 'IB_GATEWAY_DAILY_RESTART_ON_CALENDAR:-*-*-* 10:30:00 UTC' "$health_watcher_script" +grep -Fq 'gateway_mode="${1:-${IB_GATEWAY_MODE:-paper}}"' "$health_watcher_script" +grep -Fq 'compose_file="${COMPOSE_FILE:-docker-compose.yml}"' "$health_watcher_script" +grep -Fq 'Environment=COMPOSE_FILE=$compose_file' "$health_watcher_script" grep -Fq 'Environment=IB_GATEWAY_RECOVERY_LOCK_WAIT_SECONDS=0' "$health_watcher_script" grep -Fq 'OnActiveSec=$health_interval_seconds' "$health_watcher_script" ! grep -Fq 'OnBootSec=5min' "$health_watcher_script" diff --git a/tests/test_workflow_shared_config.sh b/tests/test_workflow_shared_config.sh index 2fc9fef..ccbdb41 100644 --- a/tests/test_workflow_shared_config.sh +++ b/tests/test_workflow_shared_config.sh @@ -120,4 +120,4 @@ grep -Fq 'sudo systemctl disable --now' "$maintenance_workflow_file" grep -Fq 'sudo docker update --restart=no ib-gateway' "$maintenance_workflow_file" grep -Fq 'sudo docker compose down' "$maintenance_workflow_file" grep -Fq 'sudo docker compose up -d --no-build ib-gateway' "$maintenance_workflow_file" -grep -Fq 'sudo bash ./scripts/install_gateway_health_watcher.sh' "$maintenance_workflow_file" +grep -Fq 'sudo bash ./scripts/install_gateway_health_watcher.sh __IB_GATEWAY_MODE__' "$maintenance_workflow_file"