-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstop.sh
More file actions
executable file
·36 lines (28 loc) · 797 Bytes
/
Copy pathstop.sh
File metadata and controls
executable file
·36 lines (28 loc) · 797 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
33
34
35
36
#!/bin/bash
set -euo pipefail
cd "$(dirname "$0")"
is_imgen_serve_process() {
local pid="$1"
local command
command=$(ps -p "$pid" -o command= 2>/dev/null || true)
[[ "$command" == *"serve"* ]] && \
{ [[ "$command" == *"$(pwd)/imgen"* ]] || [[ "$command" == *"./imgen"* ]] || [[ "$command" == *"imgen"* ]]; }
}
PID_FILE="logs/imgen.pid"
if [ ! -f "$PID_FILE" ]; then
echo "imgen serve is not running"
exit 0
fi
PID=$(<"$PID_FILE")
if [ -z "$PID" ] || ! kill -0 "$PID" 2>/dev/null; then
rm -f "$PID_FILE"
echo "imgen serve is not running"
exit 0
fi
if ! is_imgen_serve_process "$PID"; then
echo "PID $PID does not appear to be this repo's imgen serve process"
exit 1
fi
kill "$PID"
rm -f "$PID_FILE"
echo "imgen serve stopped (PID: $PID)"