-
Notifications
You must be signed in to change notification settings - Fork 24.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Define a templated systemd instance service unit in distribution packaging #26246
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -422,6 +422,11 @@ configure(distributions.findAll { ['deb', 'rpm'].contains(it.name) }) { | |
fileType CONFIG | NOREPLACE | ||
from "${packagingFiles}/systemd/elasticsearch.service" | ||
} | ||
configurationFile '/usr/lib/systemd/system/[email protected]' | ||
into('/usr/lib/systemd/system') { | ||
fileType CONFIG | NOREPLACE | ||
from "${packagingFiles}/systemd/[email protected]" | ||
} | ||
into('/usr/lib/sysctl.d') { | ||
fileType CONFIG | NOREPLACE | ||
from "${packagingFiles}/systemd/sysctl/elasticsearch.conf" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
[Unit] | ||
Description=Elasticsearch Instance %i | ||
Documentation=http://www.elastic.co | ||
Wants=network-online.target | ||
After=network-online.target | ||
|
||
[Service] | ||
RuntimeDirectory=elasticsearch | ||
Environment=ES_HOME=/usr/share/elasticsearch | ||
Environment=ES_PATH_CONF=${path.conf}/%i | ||
Environment=PID_DIR=/var/run/elasticsearch | ||
EnvironmentFile=-${path.env}-%i | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you think we should add There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't technically need the |
||
|
||
WorkingDirectory=/usr/share/elasticsearch | ||
|
||
User=elasticsearch | ||
Group=elasticsearch | ||
|
||
ExecStart=/usr/share/elasticsearch/bin/elasticsearch -p ${PID_DIR}/elasticsearch-%i.pid --quiet | ||
|
||
# StandardOutput is configured to redirect to journalctl since | ||
# some error messages may be logged in standard output before | ||
# elasticsearch logging system is initialized. Elasticsearch | ||
# stores its logs in /var/log/elasticsearch and does not use | ||
# journalctl by default. If you also want to enable journalctl | ||
# logging, you can simply remove the "quiet" option from ExecStart. | ||
StandardOutput=journal | ||
StandardError=inherit | ||
|
||
# Specifies the maximum file descriptor number that can be opened by this process | ||
LimitNOFILE=65536 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't really like that we have to duplicate (and maintain) all the options like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed; I tried to come up with a better way with systemd natively but I couldn't come up with a good solution. For reference, here's some feedback from #systemd on freenode:
So there's a deprecated way of doing so, and a hack to get the same effect, but nothing that looks ideal. |
||
|
||
# Specifies the maximum number of processes | ||
LimitNPROC=4096 | ||
|
||
# Specifies the maximum size of virtual memory | ||
LimitAS=infinity | ||
|
||
# Specifies the maximum file size | ||
LimitFSIZE=infinity | ||
|
||
# Disable timeout logic and wait until process is stopped | ||
TimeoutStopSec=0 | ||
|
||
# SIGTERM signal is used to stop the Java process | ||
KillSignal=SIGTERM | ||
|
||
# Send the signal only to the JVM rather than its control group | ||
KillMode=process | ||
|
||
# Java process is never killed | ||
SendSIGKILL=no | ||
|
||
# When a JVM receives a SIGTERM signal it exits with code 143 | ||
SuccessExitStatus=143 | ||
|
||
[Install] | ||
WantedBy=multi-user.target | ||
|
||
# Built for ${project.name}-${project.version} (${project.name}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can use
%I
here