Bug 195827 - Patch to textproc/apache-solr rc.d startup script to allow Solr to run on a given host and port (and as a given user)
Summary: Patch to textproc/apache-solr rc.d startup script to allow Solr to run on a g...
Status: Closed DUPLICATE of bug 195826
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-ports-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-12-09 15:56 UTC by Paul Mather
Modified: 2014-12-09 16:07 UTC (History)
2 users (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Paul Mather 2014-12-09 15:56:49 UTC
The rc.d solr startup script for textproc/apache-solr currently only allows Solr to run as root and Solr itself will bind to all available interfaces when it runs.  It is desirable to run network daemons so they will bind to a particular interface (e.g., to coexist better with Jails), and also to run as a particular user.  To that end, I've modified the /usr/local/etc/rc.d/solr startup script so that Solr can at least be bound to a particular host and port.

I've also almost achieved the latter aim of allowing Solr to be run as a non-root user.  The only thing preventing the startup script being able to do this is that is needs to ensure the /usr/local/share/examples/apache-solr/solr-webapp directory is writable by the user under which Solr is to be run.  (The solr-webapp directory is the one into which the bundled Jetty deploys Solr.)

There are two other changes to the solr rc.d script that support being able to run Solr as an unprivileged user: specifying the location of the logs and pid file.  (Both currently specify locations requiring root write access.)

The changes in the patch below support the following rc.conf settings for the solr rc.d script:

solr_host: IP address to bind to (defaults to 0.0.0.0, i.e., all interfaces)
solr_port: port to bind to (defaults to 8983)
solr_log: directory to store log files (defaults to /var/log)
solr_pidfile: location of pidfile (defaults to /var/run/solr.pid)

All the defaults default to the current behaviour of the port.  If solr_user is set in /etc/rc.conf, and the solr-webapp exists and is writable by that user, then Solr will run successfully as $solr_user, assuming solr_log and solr_pidfile point to places writable by that user.

Here is the patch to textproc/apache-solr:

--- /usr/local/etc/rc.d/solr	2014-12-08 17:47:24.509744000 -0500
+++ solr	2014-12-09 10:34:32.154587847 -0500
@@ -38,13 +38,17 @@
 
 : ${solr_enable:=NO}
 : ${solr_instance:=/var/db/solr}
+: ${solr_pidfile:=/var/run/solr.pid}
+: ${solr_log:=/var/log}
+: ${solr_host:=0.0.0.0}
+: ${solr_port:=8983}
 
 required_files=${solr_instance}/solr.xml
-pidfile=/var/run/solr.pid
+pidfile=${solr_pidfile}
 command=/usr/sbin/daemon
 procname=/usr/local/openjdk7/bin/java
 start_precmd="cd /usr/local/share/examples/apache-solr"
 
-command_args="-f -p ${pidfile} ${procname} ${solr_flags} -Dsolr.solr.home=${solr_instance} -Dsolr.log=/var/log -jar /usr/local/share/examples/apache-solr/start.jar"
+command_args="-f -p ${pidfile} ${procname} ${solr_flags} -Djetty.host=${solr_host} -Djetty.port=${solr_port} -Dsolr.solr.home=${solr_instance} -Dsolr.log=${solr_log} -jar /usr/local/share/examples/apache-solr/start.jar"
 
 run_rc_command "$1"
Comment 1 Bugzilla Automation freebsd_committer freebsd_triage 2014-12-09 15:56:49 UTC
Maintainer CC'd
Comment 2 John Marino freebsd_committer freebsd_triage 2014-12-09 16:07:03 UTC

*** This bug has been marked as a duplicate of bug 195826 ***