# Logstash init script bug

**URL:** <https://discuss.elastic.co/t/logstash-init-script-bug/48081>\
**Category:** Logstash\
**Created:** [April 21, 2016, 5:26pm UTC](https://discuss.elastic.co/t/logstash-init-script-bug/48081 "2016-04-21T17:26:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cheyenne\_Greatorex](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cheyenne_greatorex/32/9336_2.png) [@Cheyenne\_Greatorex](https://discuss.elastic.co/u/Cheyenne_Greatorex)\
**Post date:** [April 21, 2016, 5:26pm UTC](https://discuss.elastic.co/t/logstash-init-script-bug/48081/1 "2016-04-21T17:26:08Z")

</div>

When logstash doesn't stop in a timely manner, the init script exits with a bug trying to handle the timeout, and when calling it with restart, it ends up starting multiple copies.

sudo service logstash restart  
Killing logstash (pid 23698) with SIGTERM  
Waiting logstash (pid 23698) to die...  
Waiting logstash (pid 23698) to die...  
Waiting logstash (pid 23698) to die...  
Waiting logstash (pid 23698) to die...  
Waiting logstash (pid 23698) to die...  
Waiting logstash (pid 23698) to die...  
Waiting logstash (pid 23698) to die...  
Waiting logstash (pid 23698) to die...  
Waiting logstash (pid 23698) to die...  
/etc/init.d/logstash: 99: [: -eq: unexpected operator  
logstash stop failed; still running.  
logstash started.

Seen in version 2.3.1 on ubuntu 14 LTS

The relevant line in the code is...

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

```

...and that variable doesn't exist anywhere in a default configuration, hence the init script bugs out.

Addtionally, after reviewing the code further, when the else clause to the line with the bug fires, the script should not start another copy. The stop function should return an error so that "stop && start" does not do the start.

---

<div class="post-metadata">

**Author:** ![Cheyenne\_Greatorex](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cheyenne_greatorex/32/9336_2.png) [@Cheyenne\_Greatorex](https://discuss.elastic.co/u/Cheyenne_Greatorex)\
**Post date:** [April 21, 2016, 5:37pm UTC](https://discuss.elastic.co/t/logstash-init-script-bug/48081/2 "2016-04-21T17:37:08Z")

</div>

When I wrote this, I had failed to find an existing issue about it. I found one that is similar so I commented on it.

> <https://github.com/elastic/logstash/issues/4991>

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 5:01am UTC](https://discuss.elastic.co/t/logstash-init-script-bug/48081/3 "2017-07-06T05:01:14Z")

</div>


