-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.sh
More file actions
executable file
·32 lines (25 loc) · 886 Bytes
/
Copy pathrun.sh
File metadata and controls
executable file
·32 lines (25 loc) · 886 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/env bash
set -euo pipefail
# Unbuffer server output so shutdown logs can appear
python -u server/workflow_server.py 2>&1 &
server_pid=$!
# Run GUI in foreground (its logs stay normal)
python -m gui.main 2>&1 &
gui_pid=$!
shutdown_gui_then_server() {
echo "Shutting down..."
# GUI first
if [[ -n "${gui_pid:-}" ]] && kill -0 "$gui_pid" 2>/dev/null; then
kill -INT "$gui_pid" 2>/dev/null || true
wait "$gui_pid" 2>/dev/null || true
fi
# Then server: only SIGINT, then wait (let its own finally/logging run)
if [[ -n "${server_pid:-}" ]] && kill -0 "$server_pid" 2>/dev/null; then
kill -INT "$server_pid" 2>/dev/null || true
wait "$server_pid" 2>/dev/null || true
fi
}
trap 'shutdown_gui_then_server' INT TERM
# Wait for GUI; when it exits, shut down server in the intended order
wait "$gui_pid" 2>/dev/null || true
shutdown_gui_then_server