-
Notifications
You must be signed in to change notification settings - Fork 177
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #94 from hamelg/gha01
Add features to the entrypoint script
- Loading branch information
Showing
5 changed files
with
57 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,56 @@ | ||
#!/bin/sh | ||
|
||
## Inspired from the script found at | ||
## https://sanjeevan.co.uk/blog/running-services-inside-a-container-using-runit-and-alpine-linux/ | ||
|
||
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 | ||
|
||
# shutdown runsvdir command | ||
kill -HUP $RUNSVDIR | ||
wait $RUNSVDIR | ||
|
||
# give processes time to stop | ||
sleep 0.5 | ||
|
||
# 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 | ||
} | ||
|
||
. /opt/graphite/bin/activate | ||
|
||
# Ensure /usr/local/bin is in PATH. On some | ||
# weird platforms,this might not be the case | ||
PATH="${PATH}:/usr/local/bin" | ||
|
||
runsvdir -P /etc/service | ||
# 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 | ||
|
||
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 | ||
|
||
# catch shutdown signals | ||
trap shutdown SIGTERM SIGHUP SIGQUIT SIGINT | ||
wait $RUNSVDIR | ||
|
||
shutdown |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
#!/bin/sh | ||
|
||
rm -f /opt/graphite/storage/carbon-aggregator-a.pid | ||
exec python3 /opt/graphite/bin/carbon-aggregator.py start --debug 2>&1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
#!/bin/sh | ||
|
||
rm -f /opt/graphite/storage/carbon-cache-a.pid | ||
exec python3 /opt/graphite/bin/carbon-cache.py start --debug 2>&1 |