-
Notifications
You must be signed in to change notification settings - Fork 6
systemd: Use restart counter to determine if service is started #42
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
base: dev
Are you sure you want to change the base?
Changes from all commits
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 |
|---|---|---|
|
|
@@ -44,13 +44,9 @@ UMask=027 | |
| LimitNOFILE=<%= EZBake::Config[:open_file_limit] %> | ||
| <% end -%> | ||
|
|
||
| <% unless EZBake::Config[:debian][:pre_start_action].empty? -%> | ||
| PermissionsStartOnly=true | ||
| <% EZBake::Config[:debian][:pre_start_action].each do |action| -%> | ||
|
Contributor
Author
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 use those hooks for openvox-server/db, so I removed them to make the whole template more readable. |
||
| ExecStartPre=<%= action %> | ||
| <% end -%> | ||
| <% end -%> | ||
|
|
||
| # RUNTIME_DIRECTORY is set by systemd | ||
| # https://www.freedesktop.org/software/systemd/man/latest/systemd.exec.html#RuntimeDirectory= | ||
| ExecStartPre=sh -c "echo -n 0 > ${RUNTIME_DIRECTORY}/restart" | ||
| ExecStart=<%= EZBake::Config[:java_bin] %> $JAVA_ARGS -Dlogappender=F1 \ | ||
| '-XX:OnOutOfMemoryError=kill -9 %p' -XX:+CrashOnOutOfMemoryError \ | ||
| -XX:ErrorFile="${LOGS_DIRECTORY}/<%= EZBake::Config[:real_name] %>_err_pid%p.log" \ | ||
|
|
@@ -59,14 +55,18 @@ ExecStart=<%= EZBake::Config[:java_bin] %> $JAVA_ARGS -Dlogappender=F1 \ | |
| -m <%= EZBake::Config[:main_namespace] %> \ | ||
| --config "${CONFIG}" \ | ||
| --bootstrap-config "${BOOTSTRAP_CONFIG}" \ | ||
| --restart-file ${RUNTIME_DIRECTORY}/restart \ | ||
| $TK_ARGS | ||
|
|
||
| KillMode=process | ||
|
|
||
| <% EZBake::Config[:debian][:post_start_action].each do |action| -%> | ||
| ExecStartPost=-<%= action %> | ||
| <% end -%> | ||
| # wait until the service is actually up | ||
| ExecStartPost=sh -c "sleep 1; while ! head -c1 ${RUNTIME_DIRECTORY}/restart | grep -q '^1'; do kill -0 $MAINPID && sleep 1 || exit 1; done" | ||
|
|
||
| ExecReload=sh -c "echo -n 0 > ${RUNTIME_DIRECTORY}/restart" | ||
| ExecReload=kill -HUP $MAINPID | ||
| ExecReload=sh -c "while ! head -c1 ${RUNTIME_DIRECTORY}/restart | grep -q '^1'; do kill -0 $MAINPID && sleep 1 || exit 1; done" | ||
|
Contributor
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. Was omitting an initial sleep here intentional? I don't think it matters too much because checking the file contents is a cheap operation and then it will sleep anyways, the difference just caught my eye. |
||
|
|
||
| SuccessExitStatus=143 | ||
|
|
||
| [Install] | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -44,13 +44,9 @@ UMask=027 | |
| LimitNOFILE=<%= EZBake::Config[:open_file_limit] %> | ||
| <% end -%> | ||
|
|
||
| <% unless EZBake::Config[:redhat][:pre_start_action].empty? -%> | ||
| PermissionsStartOnly=true | ||
| <% EZBake::Config[:redhat][:pre_start_action].each do |action| -%> | ||
| ExecStartPre=<%= action %> | ||
| <% end -%> | ||
| <% end -%> | ||
|
|
||
| # RUNTIME_DIRECTORY is set by systemd | ||
| # https://www.freedesktop.org/software/systemd/man/latest/systemd.exec.html#RuntimeDirectory= | ||
| ExecStartPre=sh -c "echo -n 0 > ${RUNTIME_DIRECTORY}/restart" | ||
| ExecStart=<%= EZBake::Config[:java_bin] %> $JAVA_ARGS -Dlogappender=F1 \ | ||
| '-XX:OnOutOfMemoryError=kill -9 %p' -XX:+CrashOnOutOfMemoryError \ | ||
| -XX:ErrorFile="${LOGS_DIRECTORY}/<%= EZBake::Config[:real_name] %>_err_pid%p.log" \ | ||
|
|
@@ -59,14 +55,18 @@ ExecStart=<%= EZBake::Config[:java_bin] %> $JAVA_ARGS -Dlogappender=F1 \ | |
| -m <%= EZBake::Config[:main_namespace] %> \ | ||
| --config "${CONFIG}" \ | ||
| --bootstrap-config "${BOOTSTRAP_CONFIG}" \ | ||
| --restart-file ${RUNTIME_DIRECTORY}/restart \ | ||
| $TK_ARGS | ||
|
|
||
| KillMode=process | ||
|
|
||
| <% EZBake::Config[:redhat][:post_start_action].each do |action| -%> | ||
| ExecStartPost=-<%= action %> | ||
| <% end -%> | ||
| # wait until the service is actually up | ||
| ExecStartPost=sh -c "sleep 1; while ! head -c1 ${RUNTIME_DIRECTORY}/restart | grep -q '^1'; do kill -0 $MAINPID && sleep 1 || exit 1; done" | ||
|
|
||
| ExecReload=sh -c "echo -n 0 > ${RUNTIME_DIRECTORY}/restart" | ||
| ExecReload=kill -HUP $MAINPID | ||
| ExecReload=sh -c "while ! head -c1 ${RUNTIME_DIRECTORY}/restart | grep -q '^1'; do kill -0 $MAINPID && sleep 1 || exit 1; done" | ||
|
Contributor
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. same as above, just marking this in case any changes are made. |
||
|
|
||
| SuccessExitStatus=143 | ||
|
|
||
| [Install] | ||
|
|
||
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.
This would run the ExecStartPre command as root and could result into permission errors, so I removed it