mirror of
https://github.com/OpenRouterTeam/spawn.git
synced 2026-05-05 23:50:48 +00:00
refactor: use generic_ssh_wait in AWS Lightsail verify_server_connectivity
- Replace 13 lines of duplicate SSH waiting logic - Call generic_ssh_wait() with ubuntu username - Improves maintainability and reduces code duplication Score: 14 (Impact: 7, Confidence: 8, Risk: 4)
This commit is contained in:
parent
6171fa73a9
commit
a0cab9ac6e
1 changed files with 4 additions and 11 deletions
|
|
@ -133,17 +133,10 @@ create_server() {
|
|||
}
|
||||
|
||||
verify_server_connectivity() {
|
||||
local ip="${1}" max_attempts=${2:-30} attempt=1
|
||||
log_warn "Waiting for SSH connectivity to ${ip}..."
|
||||
while [[ ${attempt} -le ${max_attempts} ]]; do
|
||||
# SSH_OPTS is defined in shared/common.sh
|
||||
# shellcheck disable=SC2154,SC2086
|
||||
if ssh ${SSH_OPTS} -o ConnectTimeout=5 "ubuntu@${ip}" "echo ok" >/dev/null 2>&1; then
|
||||
log_info "SSH connection established"; return 0
|
||||
fi
|
||||
log_warn "Waiting for SSH... (${attempt}/${max_attempts})"; sleep 5; attempt=$((attempt + 1))
|
||||
done
|
||||
log_error "Server failed to respond via SSH after ${max_attempts} attempts"; return 1
|
||||
local ip="${1}" max_attempts=${2:-30}
|
||||
# Use shared generic_ssh_wait with exponential backoff
|
||||
# shellcheck disable=SC2086,SC2154
|
||||
generic_ssh_wait "ubuntu" "${ip}" "${SSH_OPTS}" "echo ok" "SSH connectivity" "${max_attempts}"
|
||||
}
|
||||
|
||||
wait_for_cloud_init() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue