Ensure service is restarted on unit file changes

At the moment we don't restart services if systemd unit file is changed.

We knowingly prevent systemd_service role handlers to execute
by providing `state: started` as otherwise service will be restarted twice.
With that now  we ensure that role handlers will also listen for systemd
unit changes.

Change-Id: I802ebfbdec5140b2414086c04ae1297868ec256b
This commit is contained in:
Dmitriy Rabotyagov 2023-04-10 15:35:42 +02:00
parent e157a116e9
commit 085a32d26f
2 changed files with 3 additions and 2 deletions

View File

@ -27,3 +27,4 @@
listen:
- "Restart uwsgi services"
- "venv changed"
- "systemd service changed"

View File

@ -44,8 +44,8 @@
systemd_TasksAccounting: true
systemd_services:
- service_name: "{{ service_var.value.service_name | default(service_var.key) }}"
enabled: yes
state: started
enabled: "{{ service_var.value.enabled | default(True) }}"
state: "{{ service_var.value.state | default('started') }}"
execstarts: "{{ uwsgi_bin }}/uwsgi --autoload --ini /etc/uwsgi/{{ service_var.key }}.ini {{ (service_var.value.uwsgi_pyargv is defined) | ternary('--pyargv \"' ~ service_var.value.uwsgi_pyargv | default('') ~ '\"', '') }}"
execreloads: "{{ uwsgi_bin }}/uwsgi --reload {{ uwsgi_run_dir }}/{{ service_var.key }}/{{ uwsgi_system_slice_name }}/{{ service_var.key }}.pid"
config_overrides: "{{ service_var.value.init_config_overrides | default({}) | combine(uwsgi_init_config_overrides, recursive=True) }}"