Skip to content

Commit

Permalink
stop all services at the same time (closes #348)
Browse files Browse the repository at this point in the history
  • Loading branch information
spujadas committed Apr 10, 2021
1 parent ade84df commit 43b7889
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion elasticsearch-init
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ case "$1" in
start-stop-daemon --stop --pidfile "$PID_FILE" \
--user "$ES_USER" \
--quiet \
--retry forever/TERM/20 > /dev/null
--retry TERM/60/KILL/5 > /dev/null
if [ $? -eq 1 ]; then
log_progress_msg "$DESC is not running but pid file exists, cleaning up"
elif [ $? -eq 3 ]; then
Expand Down
2 changes: 1 addition & 1 deletion kibana-init
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ case "$1" in

if [ -f "$PID_FILE" ]; then
start-stop-daemon --stop --pidfile "$PID_FILE" \
--retry=TERM/20/KILL/5 >/dev/null
--retry TERM/60/KILL/5 >/dev/null
if [ $? -eq 1 ]; then
log_progress_msg "$DESC is not running but pid file exists, cleaning up"
elif [ $? -eq 3 ]; then
Expand Down
17 changes: 10 additions & 7 deletions start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
#
# /usr/local/bin/start.sh
# Start Elasticsearch, Logstash and Kibana services
#
# spujadas 2015-10-09; added initial pidfile removal and graceful termination

# WARNING - This script assumes that the ELK services are not running, and is
# only expected to be run once, when the container is started.
Expand All @@ -15,12 +13,17 @@

_term() {
echo "Terminating ELK"
service elasticsearch stop
service logstash stop
service kibana stop

# kill script PGID so all the child processes are killed, to avoid zombies

# shut down services
timeout 60 service elasticsearch stop &
timeout 60 service logstash stop &
timeout 60 service kibana stop &
trap - SIGTERM SIGINT

# wait for all services to stop
wait

# kill script PGID so all the child processes are killed, to avoid zombies
kill -TERM -- -$$ 2>/dev/null
exit 0
}
Expand Down

0 comments on commit 43b7889

Please sign in to comment.