-
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathstart.sh
More file actions
46 lines (38 loc) · 896 Bytes
/
start.sh
File metadata and controls
46 lines (38 loc) · 896 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
44
45
46
#!/bin/bash
echo "[INFO] Starting app..."
yarn start &
pid=$!
# Forward signals to the child process
hup() {
echo "[SIGNAL] Caught SIGHUP. Forwarding to child ($pid)..."
kill -HUP "$pid"
wait "$pid"
exit_code=$?
echo "[INFO] Node exited with code $exit_code"
exit $exit_code
}
terminate() {
echo "[SIGNAL] Caught SIGTERM. Forwarding to child ($pid)..."
kill -TERM "$pid"
wait "$pid"
exit_code=$?
echo "[INFO] Node exited with code $exit_code"
exit $exit_code
}
interrupt() {
echo "[SIGNAL] Caught SIGINT. Forwarding to child ($pid)..."
kill -INT "$pid"
wait "$pid"
exit_code=$?
echo "[INFO] Node exited with code $exit_code"
exit $exit_code
}
# Trap signals
trap hup HUP
trap terminate TERM
trap interrupt INT
# Wait for the child normally (if no signal is caught)
wait "$pid"
exit_code=$?
echo "[INFO] Node exited with code $exit_code"
exit $exit_code