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
284 return 1284 return 1
285}285}
286 286
287stop_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
306stop_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
287start_background_services() {329start_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 1432 return 1
391}433}
392 434
435stop_existing_services
393install_web_bundle436install_web_bundle
394 437
395if [[ "$NO_MODIFY_PATH" != "1" ]]; then438if [[ "$NO_MODIFY_PATH" != "1" ]]; then