Startup script exit status should catch daemonized startup failures

This commit fixes an issue where when starting Elasticsearch in
daemonized mode, a failed startup would not cause a non-zero exit code
to be returned. This can prevent the SysV init system from detecting
startup failures.

Closes #14163
This commit is contained in:
Jason Tedor 2015-10-16 16:47:00 -04:00
parent bb8097a655
commit f1694e6663
4 changed files with 17 additions and 0 deletions

View File

@ -64,6 +64,7 @@ export ES_HEAP_NEWSIZE
export ES_DIRECT_SIZE export ES_DIRECT_SIZE
export ES_JAVA_OPTS export ES_JAVA_OPTS
export ES_GC_LOG_FILE export ES_GC_LOG_FILE
export ES_STARTUP_SLEEP_TIME
export JAVA_HOME export JAVA_HOME
lockfile=/var/lock/subsys/$prog lockfile=/var/lock/subsys/$prog

View File

@ -50,6 +50,9 @@
#ES_USER=${packaging.elasticsearch.user} #ES_USER=${packaging.elasticsearch.user}
#ES_GROUP=${packaging.elasticsearch.group} #ES_GROUP=${packaging.elasticsearch.group}
# The number of seconds to wait before checking if Elasticsearch started successfully as a daemon process
ES_STARTUP_SLEEP_TIME=${packaging.elasticsearch.startup.sleep.time}
################################ ################################
# System properties # System properties
################################ ################################

View File

@ -19,6 +19,9 @@ packaging.os.max.open.files=65535
# Maximum number of VMA (Virtual Memory Areas) a process can own # Maximum number of VMA (Virtual Memory Areas) a process can own
packaging.os.max.map.count=262144 packaging.os.max.map.count=262144
# Default number of seconds to wait before checking if Elasticsearch started successfully as a daemon process
packaging.elasticsearch.startup.sleep.time=5
# Simple marker to check that properties are correctly overridden # Simple marker to check that properties are correctly overridden
packaging.type=tar.gz packaging.type=tar.gz

View File

@ -142,6 +142,16 @@ if [ -z "$daemonized" ] ; then
else else
exec "$JAVA" $JAVA_OPTS $ES_JAVA_OPTS -Des.path.home="$ES_HOME" -cp "$ES_CLASSPATH" \ exec "$JAVA" $JAVA_OPTS $ES_JAVA_OPTS -Des.path.home="$ES_HOME" -cp "$ES_CLASSPATH" \
org.elasticsearch.bootstrap.Elasticsearch start "$@" <&- & org.elasticsearch.bootstrap.Elasticsearch start "$@" <&- &
retval=$?
pid=$!
[ $retval -eq 0 ] || exit $retval
if [ ! -z "$ES_STARTUP_SLEEP_TIME" ]; then
sleep $ES_STARTUP_SLEEP_TIME
fi
if ! ps -p $pid > /dev/null ; then
exit 1
fi
exit 0
fi fi
exit $? exit $?