Bug 226800 - textproc/elasticsearch6: Elasticsearch cannot delete its PID file
Summary: textproc/elasticsearch6: Elasticsearch cannot delete its PID file
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: amd64 Any
: --- Affects Some People
Assignee: Mark Felder
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-03-20 15:29 UTC by ftigeot
Modified: 2018-03-20 16:19 UTC (History)
1 user (show)

See Also:
bugzilla: maintainer-feedback? (feld)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description ftigeot 2018-03-20 15:29:46 UTC
textproc/elasticsearch6 sets up Elasticsearch to use a PID file located in /var/run , /var/run/elasticsearch.pid

On my system, /var/run belongs to root:wheel and has permissions 755.

When Elasticsearch is started or stopped manually by running /usr/local/etc/rc.d/elasticsearch start or stop, there is no obvious issue.

Unfortunately, in case of a system shutdown or reboot, Elasticsearch fails to start again automatically:

[2018-03-20T07:37:33,968][WARN ][o.e.b.ElasticsearchUncaughtExceptionHandler] [cube] uncaught exception in thread [Thread-2]
org.elasticsearch.ElasticsearchException: Failed to delete pid file /var/run/elasticsearch.pid
        at org.elasticsearch.common.PidFile$1.run(PidFile.java:115) ~[elasticsearch-6.2.2.jar:6.2.2]
Caused by: java.nio.file.AccessDeniedException: /var/run/elasticsearch.pid

This seems to be because Elasticsearch itself tries to remove or rewrite the PID file, and Elasticsearch is run as the elasticsearch user, not as root. It doesn't have permission to delete or create files in /var/run.

I have access to a Debian system and it uses a /run/elasticsearch/ directory belonging to elasticsearch:elasticsearch with permissions 755 to prevent the
kind of issues I am experiencing.

Would it be possible to modify this port to use a /var/run/elasticsearch/ directory ?
Comment 1 Mark Felder freebsd_committer freebsd_triage 2018-03-20 16:19:49 UTC
This should be fixed now.
Comment 2 commit-hook freebsd_committer freebsd_triage 2018-03-20 16:19:50 UTC
A commit references this bug:

Author: feld
Date: Tue Mar 20 16:19:09 UTC 2018
New revision: 465090
URL: https://svnweb.freebsd.org/changeset/ports/465090

Log:
  textproc/elasticsearch{5,6}: Pidfiles should be in a writable subdirectory

  This fixes issues Elastic has with starting/stopping in some situations

  PR:		226800

Changes:
  head/textproc/elasticsearch5/Makefile
  head/textproc/elasticsearch5/files/elasticsearch.in
  head/textproc/elasticsearch6/Makefile
  head/textproc/elasticsearch6/files/elasticsearch.in