Skip to content

Commit b5d483d

Browse files
committed
Fix systemd service template
- Remove the `RUNNING_PID` after service stop. - Restart the service on failure (this will restart the application for example on out-of-memory errors) - Honor the `deploy_log_stdout/stderr` variables
1 parent 2008ff9 commit b5d483d

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

templates/service/systemd.service.j2

+6-1
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,13 @@ After=multi-user.target
2121

2222
[Service]
2323
Type=simple
24-
ExecStartPre=/bin/rm -f {{ deploy_dir_app }}/RUNNING_PID
24+
Restart=on-failure
25+
{% if deploy_log_stdout == True or deploy_log_stderr == True %}
26+
ExecStart=/bin/sh -c "{{ deploy_dir_app }}/{{ deploy_service_start_command }} {% if deploy_log_stdout == True %}1> {{ deploy_log_stdout_path }}{% endif %} {% if deploy_log_stderr == True %}2>{{ deploy_log_stderr_path }}{% endif %}"
27+
{% else %}
2528
ExecStart={{ deploy_dir_app }}/{{ deploy_service_start_command }}
29+
{% endif %}
30+
ExecStopPost=/bin/rm -f {{ deploy_dir_app }}/RUNNING_PID
2631
WorkingDirectory={{ deploy_dir_app }}
2732
User={{ deploy_app_user }}
2833
Group={{ deploy_app_group }}

0 commit comments

Comments
 (0)