History

Restart managed services before installer updates

Rhys Sullivan committed 9 months ago

Commit e6ecdd11 parent 2636d2b1 file · +43 −0Browse files

Unified · Split

executor/install+43−0
@@ -284,6 +284,48 @@ wait_for_http() { · 283 unmodified lines
284284 return 1
285285 }
286286
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+
287329 start_background_services() {
288330 mkdir -p "$SERVICE_DIR"
289331 mkdir -p "$LOG_DIR"
@@ -390,6 +432,7 @@ wait_for_executor_ready() { · 100 unmodified lines
390432 return 1
391433 }
392434
435+stop_existing_services
393436 install_web_bundle
394437
395438 if [[ "$NO_MODIFY_PATH" != "1" ]]; then