Skip to content

Commit

Permalink
Merge pull request #394 from splunk/feature/entrypoint-signals
Browse files Browse the repository at this point in the history
Support SIGHUP and SIGTERM traps
  • Loading branch information
Ryan Faircloth authored and GitHub committed Apr 2, 2020
2 parents 26ce3ae + 4f46409 commit e467a18
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion package/sbin/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,28 @@ if [ ${SC4S_DEST_MICROFOCUS_ARCSIGHT_HEC} ]; then export SC4S_DEST_CEF_HEC=$SC4S

cd /opt/syslog-ng

# SIGTERM-handler
term_handler() {
if [ $pid -ne 0 ]; then
echo Terminating
kill -SIGTERM "$pid"
wait "$pid"
fi
exit 143; # 128 + 15 -- SIGTERM
}

# SIGHUP-handler
hup_handler() {
if [ $pid -ne 0 ]; then
echo Reloading
kill -SIGHUP "$pid"
fi
}

trap 'kill ${!}; hup_handler' SIGHUP
trap 'kill ${!}; term_handler' SIGTERM


gomplate $(find . -name *.tmpl | sed -E 's/^(\/.*\/)*(.*)\..*$/--file=\2.tmpl --out=\2/') --template t=etc/go_templates/

mkdir -p /opt/syslog-ng/etc/conf.d/local/context/
Expand All @@ -31,4 +53,11 @@ echo sc4s version=$(cat /VERSION) >/opt/syslog-ng/var/log/syslog-ng.out

echo syslog-ng starting
/opt/syslog-ng/bin/persist-tool add /opt/syslog-ng/etc/reset_persist -o /opt/syslog-ng/var
exec /opt/syslog-ng/sbin/syslog-ng $@

/opt/syslog-ng/sbin/syslog-ng -F $@ &
pid="$!"
# wait forever
while true
do
tail -f /dev/null & wait ${!}
done

0 comments on commit e467a18

Please sign in to comment.