-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathentrypoint.sh
executable file
·60 lines (44 loc) · 1.38 KB
/
entrypoint.sh
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/sh
shutdown() {
echo "shutting down container"
# first shutdown any service started by runit
for _srv in $(ls -1 /etc/service); do
sv force-stop $_srv
done
echo "shutting down runsvdir"
# shutdown runsvdir command
kill -HUP $RUNSVDIR
wait $RUNSVDIR
# give processes time to stop
sleep 0.5
echo "killing rest processes"
# kill any other processes still running in the container
for _pid in $(ps -eo pid | grep -v PID | tr -d ' ' | grep -v '^1$' | head -n -6); do
timeout -t 5 /bin/sh -c "kill $_pid && wait $_pid || kill -9 $_pid"
done
exit
}
echo "---------> Start Executing Processes <-------------"
. /opt/graphite/bin/activate
PATH="${PATH}:/usr/local/bin"
# run all scripts in the run_once folder
[ -d /etc/run_once ] && /bin/run-parts /etc/run_once
## check services to disable
for _srv in $(ls -1 /etc/service); do
eval X=$`echo -n $_srv | tr [:lower:]- [:upper:]_`_DISABLED
[ -n "$X" ] && touch /etc/service/$_srv/down
done
# remove stale pids
find /opt/graphite/storage -maxdepth 1 -name '*.pid' -delete
# chown logrotate fle (#111)
chown 0644 /etc/logrotate.d/*
exec runsvdir -P /etc/service &
RUNSVDIR=$!
echo "Started runsvdir, PID is $RUNSVDIR"
echo "wait for processes to start...."
sleep 5
for _srv in $(ls -1 /etc/service); do
sv status $_srv
done
echo "--------> Finsihed Executing Processes <---------------"
shutdown