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

Add common SystemD file for RPM/DEB package #10725

Merged
merged 1 commit into from May 27, 2015

Conversation

tlrx
Copy link
Member

@tlrx tlrx commented Apr 22, 2015

Since SystemD is well documented and supported, we don't need to have different files for DEB/RPM packages.

Tested on OpenSUSE13, Fedora 21, Debian 8 and Ubuntu 15.04 beta2.

@tlrx tlrx added v2.0.0-beta1 review :Delivery/Packaging RPM and deb packaging, tar and zip archives, shell and batch scripts v1.6.0 labels Apr 22, 2015
@tlrx
Copy link
Member Author

tlrx commented Apr 22, 2015

@electrical Can you have a look please? thanks

@tlrx
Copy link
Member Author

tlrx commented May 3, 2015

@spinscale Can you have a look please? thanks

@spinscale
Copy link
Contributor

when installing on jessie, all the output is occuring in journalctl after starting, guess this is not the desired behaviour

May 04 06:55:59 debian-800-jessie elasticsearch[664]: [2015-05-04 06:55:59,721][INFO ][node                     ] [Mar-Vell] version[2.0.0-SNAPSHOT], pid[664], build[cf7785d/2015-05-04T06:45:19Z]
May 04 06:55:59 debian-800-jessie elasticsearch[664]: [2015-05-04 06:55:59,723][INFO ][node                     ] [Mar-Vell] initializing ...
May 04 06:55:59 debian-800-jessie elasticsearch[664]: [2015-05-04 06:55:59,729][INFO ][plugins                  ] [Mar-Vell] loaded [], sites []
May 04 06:55:59 debian-800-jessie elasticsearch[664]: [2015-05-04 06:55:59,800][INFO ][env                      ] [Mar-Vell] using [1] data paths, mounts [[/ (rootfs)]], net usable_space [7.1gb], net tota
May 04 06:56:03 debian-800-jessie elasticsearch[664]: [2015-05-04 06:56:03,336][INFO ][node                     ] [Mar-Vell] initialized
May 04 06:56:03 debian-800-jessie elasticsearch[664]: [2015-05-04 06:56:03,400][INFO ][node                     ] [Mar-Vell] starting ...
May 04 06:56:03 debian-800-jessie elasticsearch[664]: [2015-05-04 06:56:03,623][INFO ][transport                ] [Mar-Vell] bound_address {inet[/0:0:0:0:0:0:0:0:9300]}, publish_address {inet[/10.0.2.15:9
May 04 06:56:03 debian-800-jessie elasticsearch[664]: [2015-05-04 06:56:03,641][INFO ][discovery                ] [Mar-Vell] elasticsearch/5OCAmEJIR6C2ALHieIfc7A
May 04 06:56:07 debian-800-jessie elasticsearch[664]: [2015-05-04 06:56:07,423][INFO ][cluster.service          ] [Mar-Vell] new_master [Mar-Vell][5OCAmEJIR6C2ALHieIfc7A][debian-800-jessie][inet[/10.0.2.1
May 04 06:56:07 debian-800-jessie elasticsearch[664]: [2015-05-04 06:56:07,450][INFO ][http                     ] [Mar-Vell] bound_address {inet[/0:0:0:0:0:0:0:0:9200]}, publish_address {inet[/10.0.2.15:9
May 04 06:56:07 debian-800-jessie elasticsearch[664]: [2015-05-04 06:56:07,451][INFO ][node                     ] [Mar-Vell] started
May 04 06:56:07 debian-800-jessie elasticsearch[664]: [2015-05-04 06:56:07,476][INFO ][gateway                  ] [Mar-Vell] recovered [0] indices into cluster_state
May 04 06:57:30 debian-800-jessie elasticsearch[664]: [2015-05-04 06:57:30,514][INFO ][cluster.metadata         ] [Mar-Vell] [foo] creating index, cause [api], templates [], shards [5]/[1], mappings []

tested this against the pr rebased against master

Update: Same happens on opensuse

@spinscale
Copy link
Contributor

we also should update docs at http://www.elastic.co/guide/en/elasticsearch/reference/current/setup-repositories.html#_apt - as we always call update-rc.d in the apt parapgraph

@tlrx tlrx force-pushed the common-systemd-for-rpm-and-deb branch from d7dc88f to c283718 Compare May 7, 2015 08:46
@tlrx
Copy link
Member Author

tlrx commented May 7, 2015

@spinscale thanks for your review. I updated the code following your comments but I was forced to rebase because of #10986.

Having STDOUT in the journal did not choke me since I find this useful. But we already log everything in the log file so I agree with you, we can skip the journal log: I added option StandardOutput for that.

I also added option StandardError so that if startup failed it will be printed in journal.

I updated the documentation here and add a one line check in tests here for #10986.

Tested on OpenSUSE13, Fedora 21, Debian 8 and Ubuntu 15.04 server.

Can you please have a look? I'd like to push this quickly and move forward on SysV init scripts. Thanks :)

@spinscale
Copy link
Contributor

Tested on

  • debian jessie: works
  • ubuntu vivid/trusty: trusty has a perms startup issue, vivid looks fine with a minor thing, see below
  • opensuse: works
  • fedora 21: works

This is the journalctl output on vivid, fedora and opensuse, maybe we should change the name just to Elasticsearch?

May 22 14:46:33 vagrant-ubuntu-vivid-64 systemd[1]: Started Starts and stops a single elasticsearch instance on this system.
May 22 14:46:33 vagrant-ubuntu-vivid-64 systemd[1]: Starting Starts and stops a single elasticsearch instance on this system...

I get this on my ubuntu trusty system, did you change anything there? The process starts, but stops again with this message (added in the -C parameter to the start-stop-daemon in the init script revealed it)

ElasticsearchException[Failed to delete pid file /var/run/elasticsearch.pid]; nested: AccessDeniedException[/var/run/elasticsearch.pid];
    at org.elasticsearch.common.PidFile$1.run(PidFile.java:115)
Caused by: java.nio.file.AccessDeniedException: /var/run/elasticsearch.pid
    at sun.nio.fs.UnixException.translateToIOException(UnixException.java:84)
    at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102)
    at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107)
    at sun.nio.fs.UnixFileSystemProvider.implDelete(UnixFileSystemProvider.java:244)
    at sun.nio.fs.AbstractFileSystemProvider.deleteIfExists(AbstractFileSystemProvider.java:108)
    at java.nio.file.Files.deleteIfExists(Files.java:1165)
    at org.elasticsearch.common.PidFile$1.run(PidFile.java:113)

@tlrx
Copy link
Member Author

tlrx commented May 26, 2015

@spinscale thanks for your review!

This is the journalctl output on vivid, fedora and opensuse, maybe we should change the name just to Elasticsearch?

Done.

I get this on my ubuntu trusty system, did you change anything there?

No, but in the meanwhile the security manager has been enabled. I fixed few things in #10986 but I did not double check the init.d scripts... The Debian script was referring to /var/run/elasticsearch.pid whereas Redhat script was referring to /var/run/elasticsearch/elasticsearch.pid. I uniformized this in this pull request (see last commit).

@tlrx tlrx force-pushed the common-systemd-for-rpm-and-deb branch from 81c8429 to e7476a0 Compare May 26, 2015 10:28
@spinscale
Copy link
Contributor

another test

# start-stop-daemon --start -C -b --user elasticsearch -c elasticsearch --pidfile /var/run/elasticsearch/elasticsearch.pid --exec /usr/share/elasticsearch/bin/elasticsearch -- -d -p /var/run/elasticsearch/elasticsearch.pid --default.config=/etc/elasticsearch/elasticsearch.yml --default.path.home=/usr/share/elasticsearch --default.path.logs=/var/log/elasticsearch --default.path.data=/var/lib/elasticsearch --default.path.conf=/etc/elasticsearch

Error: You must build the project with Maven or download a pre-built package
before you can run Elasticsearch. See 'Building from Source' in README.textile
or visit http://www.elasticsearch.org/download to get a pre-built package.

reason in /usr/share/elasticsearch/bin/elasticsearch:

IS_PACKAGED_VERSION='Elasticsearch core'
if [ "$IS_PACKAGED_VERSION" != "elasticsearch" ]; then
    cat >&2 << EOF
Error: You must build the project with Maven or download a pre-built package
before you can run Elasticsearch. See 'Building from Source' in README.textile
or visit http://www.elasticsearch.org/download to get a pre-built package.
EOF
    exit 1
fi

@tlrx
Copy link
Member Author

tlrx commented May 26, 2015

@spinscale Yes, it has been introduced by commit 6051991 and should be fixed by #11348

@spinscale
Copy link
Contributor

rebased against master and tested against older and latest ubuntu, both now start ES.
init.d based startup correctly now has the pid-file in /var/run/elasticsearch/elasticsearch.pid

Also nice sideeffect with systemd, one catches stdout/stderr and thus finds out, in case of badly configured heap

journalctl -f
-- Logs begin at Tue 2015-05-26 13:48:53 UTC. --
May 26 13:52:41 vagrant-ubuntu-vivid-64 systemd[1]: Started Elasticsearch.
May 26 13:52:41 vagrant-ubuntu-vivid-64 systemd[1]: Starting Elasticsearch...
May 26 13:52:41 vagrant-ubuntu-vivid-64 elasticsearch[1492]: Invalid initial heap size: -Xms2gb
May 26 13:52:41 vagrant-ubuntu-vivid-64 elasticsearch[1492]: Error: Could not create the Java Virtual Machine.
May 26 13:52:41 vagrant-ubuntu-vivid-64 elasticsearch[1492]: Error: A fatal exception has occurred. Program will exit.
May 26 13:52:41 vagrant-ubuntu-vivid-64 systemd[1]: elasticsearch.service: main process exited, code=exited, status=1/FAILURE
May 26 13:52:41 vagrant-ubuntu-vivid-64 systemd[1]: Unit elasticsearch.service entered failed state.
May 26 13:52:41 vagrant-ubuntu-vivid-64 systemd[1]: elasticsearch.service failed.

LGTM, thanks so much for taking this up!

@tlrx tlrx force-pushed the common-systemd-for-rpm-and-deb branch from e7476a0 to da47f77 Compare May 27, 2015 09:20
@tlrx tlrx force-pushed the common-systemd-for-rpm-and-deb branch from da47f77 to 340b7ef Compare May 27, 2015 09:52
@tlrx tlrx merged commit 340b7ef into elastic:master May 27, 2015
@kevinkluge kevinkluge removed the review label May 27, 2015
@tlrx tlrx deleted the common-systemd-for-rpm-and-deb branch May 19, 2016 09:52
@mark-vieira mark-vieira added the Team:Delivery Meta label for Delivery team label Nov 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Delivery/Packaging RPM and deb packaging, tar and zip archives, shell and batch scripts >enhancement Team:Delivery Meta label for Delivery team v1.6.0 v2.0.0-beta1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants