openstack-ansible-os_swift/templates/swift-systemd-init.j2
Kevin Carter 867f3157e9 Ensure the components are isolated from the system
This creates a specific slice which all OpenStack services will operate
from. By creating an independent slice these components will be governed
away from the system slice allowing us to better optimise resource
consumption.

See the following for more information on slices:

* https://www.freedesktop.org/software/systemd/man/systemd.slice.html

See for following for more information on resource controls:

* https://www.freedesktop.org/software/systemd/man/systemd.resource-control.html

Tools like ``systemd-cgtop`` and ``systemd-cgls`` will now give us
insight into specific processes, process groups, and resouce consumption
in ways that we've not had access to before. To enable some of this reporting
the accounting options have been added to the [Service] section of the unit
file.

Change-Id: Ibcb7d2a69ed67a99c88dc143c76aa8448d31cc9e
Signed-off-by: Kevin Carter <kevin.carter@rackspace.com>
2017-03-30 15:16:03 +00:00

43 lines
1.3 KiB
Django/Jinja

# {{ ansible_managed }}
[Unit]
Description=swift openstack service
After=syslog.target
After=network.target
[Service]
Type=simple
User={{ swift_system_user_name }}
Group={{ swift_system_group_name }}
LimitNOFILE={{ swift_soft_open_file_limits }}:{{ swift_hard_open_file_limits }}
{% if swift_pypy_enabled %}
{% if swift_pypy_gc_min is defined %}
Environment=PYPY_GC_MIN={{ swift_pypy_gc_min }}
{% endif %}
{% if swift_pypy_gc_max is defined %}
Environment=PYPY_GC_MAX={{ swift_pypy_gc_max }}
{% endif %}
{% endif %}
{% if item.value.program_override is defined %}
ExecStart={{ item.value.program_override }} {{ item.value.program_config_options|default('') }}
{% else %}
ExecStart={{ swift_bin }}/{{ item.value.program_binary | default(item.value.program_name) }} {{ item.value.program_config_options|default('') }}
{% endif %}
# Give a reasonable amount of time for the server to start up/shut down
TimeoutSec=300
Restart=on-failure
RestartSec=150
# This creates a specific slice which all services will operate from
# The accounting options give us the ability to see resource usage through
# the `systemd-cgtop` command.
Slice=swift.slice
CPUAccounting=true
BlockIOAccounting=true
MemoryAccounting=false
TasksAccounting=true
[Install]
WantedBy=multi-user.target