diff --git a/prod-run.sh b/prod-run.sh index bb26872..2c5c6fc 100755 --- a/prod-run.sh +++ b/prod-run.sh @@ -498,13 +498,16 @@ fi if [[ -n "$PID" ]]; then say "Safe restart of running bot (PID: $PID)" fi -command -v systemctl >/dev/null 2>&1 && [[ -f "$SERVICE_FILE" ]] && systemctl restart "${APP_NAME}.service" 2>/dev/null || { +if command -v systemctl >/dev/null 2>&1 && [[ -f "$SERVICE_FILE" ]]; then + systemctl restart "${APP_NAME}.service" 2>/dev/null || true +else [[ -n "$PID" ]] && kill "$PID" 2>/dev/null || true nohup node "$PROJECT_DIR/index.js" >> "$MAIN_LOG" 2>> "$ERROR_LOG" < /dev/null & disown - sleep 3 - PID="$(get_bot_pid)" -} +fi +# Always refresh PID after restart so step 11 knows the live process +sleep 3 +PID="$(get_bot_pid)" # ========================================================= # 11) POST-START HEALTH CHECK + TELEGRAM REPORT (single pass)