Skip to content

Commit 5161262

Browse files
authored
Merge pull request #20 from christianharke/fix-upstart-scripts
Fix upstart scripts
2 parents 03a5296 + 36e0d98 commit 5161262

File tree

2 files changed

+19
-10
lines changed

2 files changed

+19
-10
lines changed

defaults/main.yml

+10-4
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,15 @@ deploy_log_stderr_path: "{{ deploy_dir_logs }}/stderr.log"
112112
# If true, use deploy_service_prestart_script to run every time before the service is (re-)started
113113
deploy_service_has_prestart_script: False
114114

115+
# If true, use deploy_service_poststart_script to run every time after the service is (re-)started
116+
deploy_service_has_poststart_script: False
117+
115118
# Shell script to run if deploy_service_has_prestart_script is true
116119
deploy_service_prestart_script: ""
117120

121+
# Shell script to run if deploy_service_has_poststart_script is true
122+
deploy_service_poststart_script: ""
123+
118124
# The shell command used by the service to start your application
119125
deploy_service_start_command: "bin/{{ deploy_app_name }}"
120126

@@ -124,13 +130,13 @@ deploy_service_pidfile: "/var/run/{{ deploy_service_name }}.pid"
124130
# If true, use deploy_service_prestop_script to run every time before the service is stopped
125131
deploy_service_has_prestop_script: False
126132

127-
# If true, use deploy_service_poststop_script to run every time before the service is stopped
133+
# If true, use deploy_service_poststop_script to run every time after the service is stopped
128134
deploy_service_has_poststop_script: False
129135

130-
# Shell script to run if deploy_service_has_prestart_script is true
131-
deploy_service_preststop_script: ""
136+
# Shell script to run if deploy_service_has_prestop_script is true
137+
deploy_service_prestop_script: ""
132138

133-
# Shell script to run if deploy_service_has_prestart_script is true
139+
# Shell script to run if deploy_service_has_poststop_script is true
134140
deploy_service_poststop_script: ""
135141

136142
# If true, service will start at boot time

templates/service/upstart.conf.j2

+9-6
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,7 @@
1616

1717
description "Upstart script for {{ deploy_service_name }}"
1818
author "https://github.com/acme-software/ansible-java-deployment"
19-
version 1.0.0
20-
21-
# Set environment variables
22-
env HOME={{ deploy_dir_app }}
23-
env PIDFILE={{ deploy_service_pidfile }}
19+
version 1.0.1
2420

2521
# Respawn parameters with limit: dies 3 times within 60 seconds
2622
respawn
@@ -43,8 +39,15 @@ pre-start script
4339
end script
4440
{% endif %}
4541

42+
{% if deploy_service_has_poststart_script == True %}
43+
# Post-Start Script
44+
post-start script
45+
{{ deploy_service_poststart_script }}
46+
end script
47+
{% endif %}
48+
4649
# Execute deploy_service_start_command and log stdout
47-
exec su -c "{{ 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 %}" {{ deploy_app_user }} -- --pid $PIDFILE
50+
exec su -s /bin/sh -c '{{ 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 %}' {{ deploy_app_user }}
4851

4952
{% if deploy_service_has_prestop_script == True %}
5053
# Pre-Stop Script

0 commit comments

Comments
 (0)