-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathstart.sh
More file actions
43 lines (33 loc) · 910 Bytes
/
start.sh
File metadata and controls
43 lines (33 loc) · 910 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
37
38
39
40
41
42
43
#!/usr/bin/env bash
set -Eeuo pipefail
# ChatGPT cleaned this original script up a bit
TERM_GRACE_PERIOD="${TERM_GRACE_PERIOD:-10}"
_term() {
printf "\nCaught SIGTERM, forwarding to app..\n" >&2
kill -TERM "$child" 2>/dev/null || true
(
sleep "$TERM_GRACE_PERIOD"
if kill -0 "$child" 2>/dev/null; then
echo "App didn't exit in ${TERM_GRACE_PERIOD}s - force-killing.." >&2
kill -KILL "$child" 2>/dev/null || true
fi
) &
}
_int() {
printf "\nCaught SIGINT, forwarding to app..\n" >&2
kill -INT "$child" 2>/dev/null || true
(
sleep "$TERM_GRACE_PERIOD"
if kill -0 "$child" 2>/dev/null; then
echo "App didn't exit in ${TERM_GRACE_PERIOD}s - force-killing.." >&2
kill -KILL "$child" 2>/dev/null || true
fi
) &
}
trap _term SIGTERM
trap _int SIGINT
echo "Starting Fetcharr.."
java -jar /app/fetcharr.jar "$@" &
child=$!
wait "$child"
exit $?