31 lines
621 B
Bash
31 lines
621 B
Bash
#!/usr/bin/env bash
|
|
|
|
ROLLBACK_IN_PROGRESS="no"
|
|
|
|
rollback_on_error() {
|
|
local exit_code="${1:-1}"
|
|
local command_failed="${2:-unknown}"
|
|
|
|
if [[ "$ROLLBACK_IN_PROGRESS" == "yes" ]]; then
|
|
return
|
|
fi
|
|
ROLLBACK_IN_PROGRESS="yes"
|
|
|
|
local fail_message
|
|
fail_message="$(t deployment_failed "$exit_code" "$command_failed")"
|
|
error "$fail_message"
|
|
send_report "failed" "$fail_message"
|
|
|
|
warn "$(t rollback_starts "$SERVER_DIR")"
|
|
|
|
if [[ "${SERVICE_CREATED:-no}" == "yes" ]]; then
|
|
remove_service_if_exists
|
|
fi
|
|
|
|
if [[ -n "${LOG_FILE:-}" ]]; then
|
|
info "$(t see_log "$LOG_FILE")"
|
|
fi
|
|
|
|
exit "$exit_code"
|
|
}
|