Handling undefined $KILL_ON_STOP_TIMEOUT

In cases where $KILL_ON_STOP_TIMEOUT is undefined, getting to line 99 will generate the following error:

```
/etc/init.d/logstash: line 99: [: : integer expression expected
```

I'm no shell scripting expert, but from some tinkering I landed upon changing

```
if [ "$KILL_ON_STOP_TIMEOUT" -eq 1 ] ;
```

to

```
if [[ $KILL_ON_STOP_TIMEOUT -eq 1 ]] ;
```

which appears to work for me.

Also, logstash often takes longer than 5 seconds to shut down for me, so adding a few more seconds to the countdown on line 93 might help.

Might fix https://github.com/elastic/logstash/issues/4457

Fixes #4732
This commit is contained in:
Will Bradley 2016-02-28 13:52:39 -07:00 committed by Suyog Rao
parent 7f299f8454
commit 141d43372b

View file

@ -90,13 +90,13 @@ stop() {
echo "Killing $name (pid $pid) with SIGTERM"
kill -TERM $pid
# Wait for it to exit.
for i in 1 2 3 4 5 ; do
for i in 1 2 3 4 5 6 7 8 9; do
echo "Waiting $name (pid $pid) to die..."
status || break
sleep 1
done
if status ; then
if [ "$KILL_ON_STOP_TIMEOUT" -eq 1 ] ; then
if [[ $KILL_ON_STOP_TIMEOUT -eq 1 ]] ; then
echo "Timeout reached. Killing $name (pid $pid) with SIGKILL. This may result in data loss."
kill -KILL $pid
echo "$name killed with SIGKILL."