Skip to content

Commit 65ce7c1

Browse files
authored
Start 2FA bot after gateway recovery restarts
Start the 2FA bot immediately after gateway recovery restarts so live 2FA prompts are handled before timeout.
1 parent b0cd4a6 commit 65ce7c1

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

scripts/recover_ib_gateway_ready.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,13 @@ wait_for_ready() {
3434
bash "${script_dir}/wait_for_ib_gateway_ready.sh" "${gateway_mode}"
3535
}
3636

37+
ensure_2fa_bot_running() {
38+
CONTAINER_NAME="${container_name}" bash "${script_dir}/ensure_2fa_bot_running.sh"
39+
}
40+
3741
echo "Ensuring ${container_name} is running before readiness check."
3842
docker compose up -d --no-build
43+
ensure_2fa_bot_running
3944

4045
if wait_for_ready "${initial_wait_seconds}"; then
4146
exit 0
@@ -44,13 +49,15 @@ fi
4449
echo "IB gateway API was not ready; restarting ${container_name} and retrying." >&2
4550
docker compose ps >&2 || true
4651
docker compose restart "${container_name}"
52+
ensure_2fa_bot_running
4753

4854
if wait_for_ready "${restart_wait_seconds}"; then
4955
exit 0
5056
fi
5157

5258
echo "IB gateway API is still not ready; recreating ${container_name} and retrying." >&2
5359
docker compose up -d --force-recreate --no-build "${container_name}"
60+
ensure_2fa_bot_running
5461

5562
if wait_for_ready "${recreate_wait_seconds}"; then
5663
exit 0

tests/test_gateway_recovery_scripts.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ grep -Fq 'flock -w "${lock_wait_seconds}" 9' "$recover_script"
2626
grep -Fq 'docker compose restart "${container_name}"' "$recover_script"
2727
grep -Fq 'docker compose up -d --force-recreate --no-build "${container_name}"' "$recover_script"
2828
grep -Fq 'IB_GATEWAY_READY_TIMEOUT_SECONDS="${timeout_seconds}"' "$recover_script"
29+
grep -Fq 'CONTAINER_NAME="${container_name}" bash "${script_dir}/ensure_2fa_bot_running.sh"' "$recover_script"
30+
ensure_count="$(grep -c 'ensure_2fa_bot_running' "$recover_script")"
31+
test "$ensure_count" -ge 4
2932

3033
grep -Fq 'swap_size_mib="${IB_GATEWAY_SWAP_SIZE_MIB:-2048}"' "$swap_script"
3134
grep -Fq 'fallocate -l "${swap_size_mib}M" "${swap_file}"' "$swap_script"

0 commit comments

Comments
 (0)