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 ?
This should be fixed now.
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