Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide systemd unit file #3606

Closed
dbrgn opened this issue Jul 14, 2015 · 14 comments
Closed

Provide systemd unit file #3606

dbrgn opened this issue Jul 14, 2015 · 14 comments

Comments

@dbrgn
Copy link

dbrgn commented Jul 14, 2015

Would be nice if you could provide a systemd unit file in addition to the SysV and Upstart init scripts. Especially now that Debian 8 has moved to systemd by default.

@jordansissel
Copy link
Contributor

In the meantime, you can use pleaserun to generate this:

# Run on your target server
% pleaserun -p systemd -v default --install /opt/logstash/bin/logstash agent -f /etc/logstash.conf
% systemctl enable logstash
% systemctl start logstash

@jordansissel
Copy link
Contributor

Solving this I think will require packages that target specific OS distros and versions. We don't have this today, but will think about how to solve it.

@dbrgn
Copy link
Author

dbrgn commented Jul 14, 2015

In the meantime, you can use pleaserun to generate this

Thanks!

@putztzu
Copy link

putztzu commented Aug 13, 2015

So, this verifies why a logstash systemd Unit file doesn't exist.
Can someone explain then how my systemd commands (on an openSUSE 13.2) is hooked into supporting logstash installed from the official logstash repo? Should be the same as how LS would be installed on Fedora.

Someone must have done something very original to enable standard "systemctl enable/disable/start/restart/stop logstash.service" to perform without a Unit file. Unless the magic is somehow not in the logstash codebase and a new feature in systemd I'm not aware of (auto support of initV by scanning /etc/init.d/ and simulating Unit files?)

TIA.

@jordansissel
Copy link
Contributor

Someone must have done something very original to enable standard "systemctl enable/disable/start/restart/stop logstash.service" to perform without a Unit file

Systemd has magic to have scripts in /etc/init.d/xxx appear implicitly as systemd services so they can be controlled from the normal systemctl start etc. This feature likely exists for backwards compatibility and easier transitioning to systemd, but that is just my guess.

Hope this helps explain.

@rgevaert
Copy link
Contributor

@jordansissel systemd-sysv-generator generates on the fly unit files. However because of a design decision in systemd starting logstash doesn't work if logstash was not cleanly stopped (meaning through systemd stop).

Reproduce with (on a systemd enabled machine):

  1. kill logstash process
  2. systemctl start logstash
    You will see that logstash isn't started.
  3. systemctl stop logstash
  4. systemctl start logstash
    You will see logstash is started.

The reasons for this is that 'systemd-sysv-generator' by default puts "RemainAfterExit=yes". While it should be 'RemainAfterExit=no' for the [Service] block.

An override systemd section file can be found at https://gist.github.com/rgevaert/94094e94ffb420ab84a6

Here is a reference to a bugreport in discussing why systemd behaves this way. systemd/systemd#1211

@m1keil
Copy link

m1keil commented Dec 1, 2015

@rgevaert Thank you for pointing in the right direction

@Xylakant
Copy link

Solving this I think will require packages that target specific OS distros and versions. We don't have this today, but will think about how to solve it.

Separate packages should not be required: common practice seems to be to just provide both an init script and a unit file. systemctl will ignore the init script if a unit file is present. Distributions that don't have systemd will ignore the unit file

@zabbal
Copy link

zabbal commented Dec 21, 2015

If you have trouble writing .service file you can take https://github.com/guardian/machine-images/blob/master/packer/resources/features/elk-stack/systemd-logstash.service as an example. But this really belongs to both upstream and packages.

@dhollinger
Copy link

@zabbal Nice job, though the .service file should not require elasticsearch.service since not all implementations of Logstash use the elasticsearch plugins for input or output.

I agree that this needs to be included in the DEB and RPM packages. Many, if not all, major distributions used in the Enterprise have switched over the SystemD for service management.

@Xylakant
Copy link

Xylakant commented Jan 5, 2016

due to #4420 systemd might report a crashing logstash process as inactive (dead) instead of failed.

@strootman
Copy link

#4420 has been closed.

@strootman
Copy link

It would be nice to have logstash install via systemd. At least for the sake of consistency with the other products (beats, elasticsearch, kibana).

@suyograo
Copy link
Contributor

suyograo commented May 29, 2016

Fixed in #5341 available in 5.0.0-alpha3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants