Init.d missing - CentOS 6.8 - 5.0.0rc1

Running CentOS 6.8, installing 5.0.0 RC1 through yum following the instructions in the docs (https://www.elastic.co/guide/en/logstash/5.0/installing-logstash.html) and the init.d scripts are missing for starting/stopping logstash.

Using the following repo config, had to turn gpgcheck off as it appears 5.0.0rc1 is not signed:

[logstash-5.x]
name=Elastic repository for 5.x packages
baseurl=https://artifacts.elastic.co/packages/5.x-prerelease/yum
gpgcheck=0
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=1
autorefresh=1
type=rpm-md

Installed logstash using sudo yum install logstash

Running Transaction
  Installing : 1:logstash-5.0.0~rc1-1.noarch                                1/1
chmod: cannot access `/etc/logrotate.d/logstash': No such file or directory
Using provided startup.options file: /etc/logstash/startup.options
Successfully created system startup script for Logstash

Try to chkconfig it like the docs say:

# chkconfig --add logstash
error reading information on service logstash: No such file or directory

It definitely did not create any file in /etc/init.d:

# ls -la /etc/init.d/logstash
ls: cannot access /etc/init.d/logstash: No such file or directory

It did create a file in /etc/init:

 # cat /etc/init/logstash.conf
description     "logstash"
start on filesystem or runlevel [2345]
stop on runlevel [!2345]

respawn
umask 022
#nice 19
#chroot /
#chdir /
#limit core <softlimit> <hardlimit>
#limit cpu <softlimit> <hardlimit>
#limit data <softlimit> <hardlimit>
#limit fsize <softlimit> <hardlimit>
#limit memlock <softlimit> <hardlimit>
#limit msgqueue <softlimit> <hardlimit>
#limit nice <softlimit> <hardlimit>
#limit nofile <softlimit> <hardlimit>
#limit nproc <softlimit> <hardlimit>
#limit rss <softlimit> <hardlimit>
#limit rtprio <softlimit> <hardlimit>
#limit sigpending <softlimit> <hardlimit>
#limit stack <softlimit> <hardlimit>


exec chroot --userspec logstash:logstash / /usr/share/logstash/bin/logstash "--path.settings" "/etc/logstash"

This is a fresh OS install and fresh logstash install.

Java version:

 # java -version
java version "1.8.0_73"
Java(TM) SE Runtime Environment (build 1.8.0_73-b02)
Java HotSpot(TM) 64-Bit Server VM (build 25.73-b02, mixed mode)

Previous Logstash package versions did install a generic init.d script. Starting with 5.0, DEB and RPM installations of Logstash install the specific kind of startup script called for by the linux distribution. See https://www.elastic.co/guide/en/logstash/5.0/running-logstash.html

So, for CentOS 6.8, that would be Upstart. Start Logstash with sudo initctl start logstash.

All of these setup changes are documented at https://www.elastic.co/guide/en/logstash/5.0/setup-logstash.html, along with the rest of the changes and differences between 5.0 and previous versions.

Well that explains that,

That did the trick, first thing using upstart, everything else on the system is still old sysv

Even running the ps -p 1 shows init on this system so why i assumed there would be an init.d file based on the documentation for installing:

Configure Logstash to automatically start during bootup. If your distribution is using SysV init (check with ps -p 1), then you will need to run:
chkconfig --add logstash

Yeah. I don't know why RedHat did that. As you've discovered, it's a hybrid approach that uses init, but also uses upstart. Logstash detects the upstart, so that's what it's using. It's actually more effective, so there's that.

Yes, I ran into this same thing. It seems off that not all components of the stack have the same start up method.

Thank you for the info, while it does state that in the doc, I kept thinking "it must be wrong, not of the others use that method."

That was my thinking too, it seemed odd with all the unification of the stack with 5.0.0 that one of the components would start different, it still bothers me but i can get over it.

Hi jaaplaya.

I had similar problems as well.
I have not checked the rpm and github for sample code of /etc/init/logstash.

It seems that it is not official recommended startup method, but since I had code for SysV in the past pull request, I coped by rewriting the DAEMON variable of this code.
It will be helpful.

I think that you can solve the problem by modifying the spec file at rpm generation or by modifying after-install.sh.
However, I can not judge because there is no official rpm build environment.
https://github.com/elastic/logstash/blob/master/pkg/centos/after-install.sh

[USER@SERVER ~]$ rpm -qp --scripts logstash-5.0.1.rpm 
preinstall scriptlet (using /bin/sh):
# create logstash group
if ! getent group logstash >/dev/null; then
  groupadd -r logstash
fi

# create logstash user
if ! getent passwd logstash >/dev/null; then
  useradd -r -g logstash -d /usr/share/logstash \
    -s /sbin/nologin -c "logstash" logstash
fi
postinstall scriptlet (using /bin/sh):
chown -R logstash:logstash /usr/share/logstash
chown -R logstash /var/log/logstash
chown logstash:logstash /var/lib/logstash
sed -i \
  -e 's|# path.config:|path.config: /etc/logstash/conf.d|' \
  -e 's|# path.logs:|path.logs: /var/log/logstash|' \
  -e 's|# path.data:|path.data: /var/lib/logstash|' \
  /etc/logstash/logstash.yml
/usr/share/logstash/bin/system-install /etc/logstash/startup.options
preuninstall scriptlet (using /bin/sh):
# CentOS/RHEL and SuSE
if [ $1 -eq 0 ]; then
  # Upstart
  if [ -r "/etc/init/logstash.conf" ]; then
    if [ -f "/sbin/stop" ]; then
      /sbin/stop logstash >/dev/null 2>&1 || true
    else
      /sbin/service logstash stop >/dev/null 2>&1 || true
    fi
    if [ -f "/etc/init/logstash.conf" ]; then
      rm /etc/init/logstash.conf
    fi
  # SYSV
  elif [ -r "/etc/init.d/logstash" ]; then
    /sbin/chkconfig --del logstash
    if [ -f "/etc/init.d/logstash" ]; then
      rm /etc/init.d/logstash
    fi
  # systemd
  else
    systemctl stop logstash >/dev/null 2>&1 || true
    if [ -f "/etc/systemd/system/logstash-prestart.sh" ]; then
      rm /etc/systemd/system/logstash-prestart.sh
    fi

    if [ -f "/etc/systemd/system/logstash.service" ]; then
      rm /etc/systemd/system/logstash.service
    fi
  fi
  if getent passwd logstash >/dev/null ; then
    userdel logstash
  fi

  if getent group logstash > /dev/null ; then
    groupdel logstash
  fi
fi