spujadas / elk-docker

Elasticsearch, Logstash, Kibana (ELK) Docker image
Other
2.16k stars 908 forks source link

suggestion: try to stop all services at the same time #348

Closed ollofx closed 3 years ago

ollofx commented 3 years ago

initiate stop service at the same time for all services then disable signal trap and wait for service stop to complete

start.sh:16

_term() {
  echo "Terminating ELK"
  service elasticsearch stop &
  service logstash stop &
  service kibana stop &
  trap - SIGTERM SIGINT
  # wait all stop tasks to complete
  wait
  # kill script PGID so all the child other the direct child are killed avoid zombies
  kill -TERM -- -$$ 2>/dev/null
  exit 0
}
ollofx commented 3 years ago

the only issue is that service stop could wait forever

elasticsearch replace forever/TERM/20 instead of TERM/60/KILL/5 for instance /etc/init.d/kibana

/etc/init.d/eleaticsearch

        log_daemon_msg "Stopping $DESC"

        if [ -f "$PID_FILE" ]; then
            start-stop-daemon --stop --pidfile "$PID_FILE" \
                --user "$ES_USER" \
                --quiet \
                --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
                PID="`cat $PID_FILE`"
                log_failure_msg "Failed to stop $DESC (pid $PID)"
                exit 1
            fi
            rm -f "$PID_FILE"
spujadas commented 3 years ago

Great suggestion, thanks @ollofx!