-
-
Save Daniel-KM/1fb475a47340d7945fa6c47c945707d0 to your computer and use it in GitHub Desktop.
systemd service file for Apache SOLR
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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/solr.in.sh 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 https://confluence.t5.fi/display/~stefan.roos/2015/04/01/Creating+systemd+unit+(service)+for+Apache+Solr | |
[Unit] | |
Description=Apache SOLR | |
ConditionPathExists=/opt/solr | |
After=syslog.target network.target remote-fs.target nss-lookup.target systemd-journald-dev-log.socket | |
Before=multi-user.target | |
Conflicts=shutdown.target | |
StartLimitIntervalSec=60 | |
[Service] | |
User=solr | |
LimitNOFILE=1048576 | |
LimitNPROC=1048576 | |
PIDFile=/var/solr/solr-8983.pid | |
Environment=SOLR_INCLUDE=/etc/default/solr.in.sh | |
Environment=RUNAS=solr | |
Environment=SOLR_INSTALL_DIR=/opt/solr | |
ExecStart=/opt/solr/bin/solr start | |
ExecStop=/opt/solr/bin/solr stop | |
Restart=on-failure | |
RestartSec=5 | |
[Install] | |
WantedBy=multi-user.target |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The shipped systemd service definition is flawed (as of Solr v9.5.0) as it fails to restart the service in case it crashes. I figured that the hard way yesterday. Using this template for now.