elastic / elastic/logstash

init.d script in the .deb packages doesn't return correct exit statuses

Open
#4,817 4 comments 0 reactions 0 assignees View on GitHub
bug packaging
Dominant language
Java
Stars
14.9k
Forks
3.5k
Avg merge
19h 14m
Merged PRs (30d)
63

Description

I occasionally run into some issues on my ELK system (running on Debian Jessie) where logstash is not restarted correctly. It looks like this is because it takes too long to shut down, and the exit status of the init script is not correct. My syslog looks like this:

```
Mar 15 11:06:07 elk systemd[1]: Stopping LSB: Starts Logstash as a daemon....
Mar 15 11:06:07 elk logstash[9575]: Killing logstash (pid 26029) with SIGTERM
Mar 15 11:06:07 elk logstash[9575]: Waiting logstash (pid 26029) to die...
Mar 15 11:06:08 elk logstash[9575]: Waiting logstash (pid 26029) to die...
Mar 15 11:06:09 elk logstash[9575]: Waiting logstash (pid 26029) to die...
Mar 15 11:06:10 elk logstash[9575]: Waiting logstash (pid 26029) to die...
Mar 15 11:06:11 elk logstash[9575]: Waiting logstash (pid 26029) to die...
Mar 15 11:06:12 elk logstash[9575]: logstash stop failed; still running.
Mar 15 11:06:12 elk systemd[1]: Starting LSB: Starts Logstash as a daemon....
Mar 15 11:06:13 elk logstash[9813]: logstash is already running
Mar 15 11:06:13 elk systemd[1]: Started LSB: Starts Logstash as a daemon..
```

I think the main issue here is that in both the stop and the start cases, the init script is not returning the correct exit status. It looks like if the "stop" action fails, it returns a zero exit status instead of a non-zero one as it should. Likewise it returns a zero exit status if the start action fails, when this should be non-zero. I believe that if it was returning the correct exit statuses, systemd would be able to deal with the restart and the service would not die.

Looking at git, I can see that the init script on my system (installed from http://packages.elasticsearch.org/logstash/2.2/debian) is coming from `pkg/logstash.sysv` and not `pkg/logstash.sysv.debian`. At a quick glance, the `pkg/logstash.sysv.debian` init script should work correctly, but it seems this file is not actually being used as the init script in the deb packages (which seems wrong).

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.