-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.sh
More file actions
33 lines (27 loc) · 675 Bytes
/
run.sh
File metadata and controls
33 lines (27 loc) · 675 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
#!/bin/bash
set -e
shutdown(){
echo "Shutting Down"
ls /etc/service | SHELL=/bin/sh parallel --no-notice sv force-stop {}
if [ -e /proc/$RUNSVDIR ]; then
kill -HUP $RUNSVDIR
wait $RUNSVDIR
fi
sleep 1
ORPHANS=`ps -eo pid | grep -v PID | tr -d ' ' | grep -v '^1$'`
SHELL=/bin/bash parallel --no-notice 'timeout 5 /bin/bash -c "kill {} && wait {}" || kill -9 {}' ::: $ORPHANS 2> /dev/null
exit
}
startup(){
/etc/init.d/grafana-server start
exec runsvdir -P /etc/service &
RUNSVDIR=$!
echo "Started runsvdir, PID is $RUNSVDIR"
trap shutdown SIGTERM SIGHUP SIGINT
wait $RUNSVDIR
shutdown
}
main(){
startup
}
main