Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
systemd service file for Apache SOLR
# put this file in /etc/systemd/system/ as root
# below paths assume solr installed in /opt/solr, SOLR_PID_DIR is /data
# and that all configuration exists in /etc/default/ which is the case if previously installed as an init.d service
# change port in pid file if differs
# note that it is configured to auto restart solr if it fails (Restart=on-faliure) and that's the motivation indeed :)
# to switch from systemv (init.d) to systemd, do the following after creating this file:
# sudo systemctl daemon-reload
# sudo service solr stop # if already running
# sudo systemctl enable solr
# systemctl start solr
# this was inspired by
Description=Apache SOLR systemd-journald-dev-log.socket nginx.service
ExecStart=/opt/solr/bin/solr start
ExecStop=/opt/solr/bin/solr stop

This comment has been minimized.

Copy link
Owner Author

commented Jan 9, 2017

Note that it delays nginx.service in case it is used as reverse proxy for the solr upstream


This comment has been minimized.

Copy link

commented Apr 28, 2018

seems like Restart=on-failure makes Solr restart forever. Did it work for you?


This comment has been minimized.

Copy link

commented Jan 24, 2019

Note you will probably need to add the following in your [Service] stanza:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.