
When not using dedicated replication systemd still puts init scripts down, which take a long time to restart/start. upstart scripts get around this by setting blank scripts. Now that we are using a service dict we can do better by defining an "service_en" flag and not setting up scripts when the service isn't enabled. Additionally, the systemd tempfiles and init files were not using the appropriate "program_binary" variable at all, this has been fixed. Change-Id: Iae569bfe38a440fb09e56658b3a934799a8821e8
40 lines
1.5 KiB
Django/Jinja
40 lines
1.5 KiB
Django/Jinja
# {{ ansible_managed }}
|
|
description "{{ item.value.program_name }}"
|
|
author "Kevin Carter <kevin.carter@rackspace.com>"
|
|
|
|
start on runlevel [2345]
|
|
stop on runlevel [016]
|
|
|
|
respawn
|
|
respawn limit 10 5
|
|
|
|
# Set the RUNBIN environment variable
|
|
env RUNBIN="{{ swift_bin }}/{{ item.value.program_binary | default(item.value.program_name) }}"
|
|
|
|
# Change directory to service users home
|
|
chdir "{{ swift_system_home_folder }}"
|
|
|
|
# Pre start actions
|
|
pre-start script
|
|
mkdir -p "/var/run/{{ item.value.program_binary | default(item.value.program_name) }}"
|
|
chown {{ swift_system_user_name }}:{{ swift_system_group_name }} "/var/run/{{ item.value.program_binary | default(item.value.program_name) }}"
|
|
|
|
mkdir -p "/var/lock/{{ item.value.program_binary | default(item.value.program_name) }}"
|
|
chown {{ swift_system_user_name }}:{{ swift_system_group_name }} "/var/lock/{{ item.value.program_binary | default(item.value.program_name) }}"
|
|
|
|
. {{ swift_bin }}/activate
|
|
|
|
end script
|
|
|
|
# Post stop actions
|
|
post-stop script
|
|
rm "/var/run/{{ item.value.program_binary | default(item.value.program_name) }}/{{ item.value.program_name }}.pid"
|
|
end script
|
|
|
|
# Run the start up job
|
|
exec start-stop-daemon --start \
|
|
--chuid {{ swift_system_user_name }} \
|
|
--make-pidfile \
|
|
--pidfile /var/run/{{ item.value.program_binary | default(item.value.program_name) }}/{{ item.value.program_name }}.pid \
|
|
--exec "{{ item.value.program_override|default('$RUNBIN') }}" "{{ item.value.program_config_options|default('') }}"
|