name variables and don't always use the timeout
This commit is contained in:
parent
71aefd5a06
commit
2473e7499b
|
@ -265,6 +265,8 @@ start_elasticsearch_service() {
|
||||||
# $1 expected status code
|
# $1 expected status code
|
||||||
# $2 additional command line args
|
# $2 additional command line args
|
||||||
run_elasticsearch_service() {
|
run_elasticsearch_service() {
|
||||||
|
local expectedStatus=$1
|
||||||
|
local commandLineArgs=$2
|
||||||
# Set the CONF_DIR setting in case we start as a service
|
# Set the CONF_DIR setting in case we start as a service
|
||||||
if [ ! -z "$CONF_DIR" ] ; then
|
if [ ! -z "$CONF_DIR" ] ; then
|
||||||
if is_dpkg ; then
|
if is_dpkg ; then
|
||||||
|
@ -279,9 +281,12 @@ run_elasticsearch_service() {
|
||||||
local CONF_DIR=""
|
local CONF_DIR=""
|
||||||
fi
|
fi
|
||||||
# we must capture the exit code to compare so we don't want to start as background process in case we expect something other than 0
|
# we must capture the exit code to compare so we don't want to start as background process in case we expect something other than 0
|
||||||
BACKGROUND=""
|
local background=""
|
||||||
if [ $1 = 0 ]; then
|
local timeoutCommand=""
|
||||||
BACKGROUND="-d"
|
if [ "$expectedStatus" = 0 ]; then
|
||||||
|
background="-d"
|
||||||
|
else
|
||||||
|
timeoutCommand="timeout 60s "
|
||||||
fi
|
fi
|
||||||
# su and the Elasticsearch init script work together to break bats.
|
# su and the Elasticsearch init script work together to break bats.
|
||||||
# sudo isolates bats enough from the init script so everything continues
|
# sudo isolates bats enough from the init script so everything continues
|
||||||
|
@ -292,9 +297,9 @@ run_elasticsearch_service() {
|
||||||
# This line is attempting to emulate the on login behavior of /usr/share/upstart/sessions/jayatana.conf
|
# This line is attempting to emulate the on login behavior of /usr/share/upstart/sessions/jayatana.conf
|
||||||
[ -f /usr/share/java/jayatanaag.jar ] && export JAVA_TOOL_OPTIONS="-javaagent:/usr/share/java/jayatanaag.jar"
|
[ -f /usr/share/java/jayatanaag.jar ] && export JAVA_TOOL_OPTIONS="-javaagent:/usr/share/java/jayatanaag.jar"
|
||||||
# And now we can start Elasticsearch normally, in the background (-d) and with a pidfile (-p).
|
# And now we can start Elasticsearch normally, in the background (-d) and with a pidfile (-p).
|
||||||
timeout 60s /tmp/elasticsearch/bin/elasticsearch $BACKGROUND -p /tmp/elasticsearch/elasticsearch.pid -Des.path.conf="$CONF_DIR" $2
|
$timeoutCommand/tmp/elasticsearch/bin/elasticsearch $background -p /tmp/elasticsearch/elasticsearch.pid -Des.path.conf=$CONF_DIR $commandLineArgs
|
||||||
BASH
|
BASH
|
||||||
[ "$status" -eq $1 ]
|
[ "$status" -eq "$expectedStatus" ]
|
||||||
elif is_systemd; then
|
elif is_systemd; then
|
||||||
run systemctl daemon-reload
|
run systemctl daemon-reload
|
||||||
[ "$status" -eq 0 ]
|
[ "$status" -eq 0 ]
|
||||||
|
@ -306,11 +311,11 @@ BASH
|
||||||
[ "$status" -eq 0 ]
|
[ "$status" -eq 0 ]
|
||||||
|
|
||||||
run systemctl start elasticsearch.service
|
run systemctl start elasticsearch.service
|
||||||
[ "$status" -eq $1 ]
|
[ "$status" -eq "$expectedStatus" ]
|
||||||
|
|
||||||
elif is_sysvinit; then
|
elif is_sysvinit; then
|
||||||
run service elasticsearch start
|
run service elasticsearch start
|
||||||
[ "$status" -eq $1 ]
|
[ "$status" -eq "$expectedStatus" ]
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue