Unified · Split
| @@ -284,6 +284,48 @@ wait_for_http() { · 283 unmodified lines | |||
| 284 | return 1 | 284 | return 1 |
| 285 | } | 285 | } |
| 286 | 286 | ||
| 287 | stop_pid_file() { | ||
| 288 | local pid_file="$1" | ||
| 289 | if [[ ! -f "$pid_file" ]]; then | ||
| 290 | return | ||
| 291 | fi | ||
| 292 | |||
| 293 | local pid | ||
| 294 | pid="$(cat "$pid_file" 2>/dev/null || true)" | ||
| 295 | if [[ -n "$pid" ]] && is_pid_running "$pid"; then | ||
| 296 | kill "$pid" >/dev/null 2>&1 || true | ||
| 297 | sleep 1 | ||
| 298 | if is_pid_running "$pid"; then | ||
| 299 | kill -9 "$pid" >/dev/null 2>&1 || true | ||
| 300 | fi | ||
| 301 | fi | ||
| 302 | |||
| 303 | rm -f "$pid_file" | ||
| 304 | } | ||
| 305 | |||
| 306 | stop_existing_services() { | ||
| 307 | local likely_running=0 | ||
| 308 | |||
| 309 | if wait_for_http "http://127.0.0.1:${BACKEND_PORT}/version" 2; then | ||
| 310 | likely_running=1 | ||
| 311 | fi | ||
| 312 | if wait_for_http "http://127.0.0.1:${WEB_PORT}/" 2; then | ||
| 313 | likely_running=1 | ||
| 314 | fi | ||
| 315 | if [[ -f "$BACKEND_PID_FILE" || -f "$WEB_PID_FILE" ]]; then | ||
| 316 | likely_running=1 | ||
| 317 | fi | ||
| 318 | |||
| 319 | if (( likely_running == 0 )); then | ||
| 320 | return | ||
| 321 | fi | ||
| 322 | |||
| 323 | echo -e "${MUTED}Stopping existing managed services before update${NC}" | ||
| 324 | "$INSTALL_DIR/$APP" down >/dev/null 2>&1 || true | ||
| 325 | stop_pid_file "$WEB_PID_FILE" | ||
| 326 | stop_pid_file "$BACKEND_PID_FILE" | ||
| 327 | } | ||
| 328 | |||
| 287 | start_background_services() { | 329 | start_background_services() { |
| 288 | mkdir -p "$SERVICE_DIR" | 330 | mkdir -p "$SERVICE_DIR" |
| 289 | mkdir -p "$LOG_DIR" | 331 | mkdir -p "$LOG_DIR" |
| @@ -390,6 +432,7 @@ wait_for_executor_ready() { · 100 unmodified lines | |||
| 390 | return 1 | 432 | return 1 |
| 391 | } | 433 | } |
| 392 | 434 | ||
| 435 | stop_existing_services | ||
| 393 | install_web_bundle | 436 | install_web_bundle |
| 394 | 437 | ||
| 395 | if [[ "$NO_MODIFY_PATH" != "1" ]]; then | 438 | if [[ "$NO_MODIFY_PATH" != "1" ]]; then |