Skip to content

Commit

Permalink
Merge pull request #12 from acme-software/redirect_err_to_stdout_upstart
Browse files Browse the repository at this point in the history
Redirect err to stdout upstart
  • Loading branch information
frne authored Jul 26, 2018
2 parents 056c7a6 + 4809978 commit c2331b0
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
13 changes: 13 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ deploy_log_stdout: True

deploy_log_stdout_path: "{{ deploy_dir_logs }}/stdout.log"

deploy_log_stderr: True

deploy_log_stderr_path: "{{ deploy_dir_logs }}/stderr.log"

# Service
###############################################

Expand All @@ -117,6 +121,15 @@ deploy_service_start_command: "bin/{{ deploy_app_name }}"
# PID file location for service installation
deploy_service_pidfile: "/var/run/{{ deploy_service_name }}.pid"

# If true, use deploy_service_prestop_script to run every time before the service is stopped
deploy_service_has_preststop_script: False

# Shell script to run if deploy_service_has_prestart_script is true
deploy_service_preststop_script: ""

# If true, service will start at boot time
deploy_start_at_boot_time: False

# Which service wrapper / systemloader you want to use
#
# This can be default, upstart, systemd or none
Expand Down
16 changes: 15 additions & 1 deletion templates/service/upstart.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ env PIDFILE={{ deploy_service_pidfile }}
respawn
respawn limit 3 60

{% if deploy_start_at_boot_time == True %}
# When to start the service
start on runlevel [2345]
# When to stop the service
stop on runlevel [016]
{% endif %}

# Change directory to current version of Tankmin
chdir {{ deploy_dir_app }}

Expand All @@ -37,4 +44,11 @@ end script
{% endif %}

# Execute deploy_service_start_command and log stdout
exec su -c "{{ deploy_service_start_command }} {% if deploy_log_stdout == True %}>>{{ deploy_log_stdout_path }}{% endif %}" {{ deploy_app_user }} -- --pid $PIDFILE
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

{% if deploy_service_has_prestop_script == True %}
# Pre-Stop Script
pre-stop script
{{ deploy_service_prestop_script }}
end script
{% endif %}

0 comments on commit c2331b0

Please sign in to comment.