Zammad: control restart behaviour via systemd

This commit is contained in:
phil 2023-12-06 20:31:38 +01:00
parent 95a3ba934c
commit 824b7de935
8 changed files with 9 additions and 43 deletions

View file

@ -31,9 +31,6 @@
- import_tasks: systemd.yml
tags: systemd
- import_tasks: monit.yml
tags: monit
- import_tasks: gateway.yml
tags: gateway

View file

@ -1,5 +0,0 @@
- name: "monit: Kopiere Konfiguration"
template:
src: monit.j2
dest: /etc/monit/conf-enabled/zammad
notify: reload monit

View file

@ -1,22 +0,0 @@
check process {{ zammad_rails_service | splitext | first }} with pidfile {{ zammad_home }}/tmp/pids/server.pid
start program = "/usr/sbin/service {{ zammad_rails_service | splitext | first }} start"
stop program = "/usr/sbin/service {{ zammad_rails_service | splitext | first }} stop"
if 2 restarts within 3 cycles then timeout
if cpu usage > 95% for 3 cycles then restart
if failed host 127.0.0.1 port 3000 for 3 cycles then restart
check process {{ zammad_websocket_service | splitext | first }}
matching "script/websocket-server.rb -b 127.0.0.1 -p 6042 start"
start program = "/usr/sbin/service {{ zammad_websocket_service | splitext | first }} start"
stop program = "/usr/sbin/service {{ zammad_websocket_service | splitext | first }} stop"
if 2 restarts within 3 cycles then timeout
if cpu usage > 95% for 3 cycles then restart
if failed host 127.0.0.1 port 6042 for 3 cycles then restart
check process {{ zammad_worker_service | splitext | first }}
matching "script/background-worker.rb start"
start program = "/usr/sbin/service {{ zammad_worker_service | splitext | first }} start"
stop program = "/usr/sbin/service {{ zammad_worker_service | splitext | first }} stop"
if 2 restarts within 3 cycles then timeout
if cpu usage > 95% for 3 cycles then restart
if 5 restarts within 5 cycles then timeout

View file

@ -1,11 +1,13 @@
### {{ ansible_managed }}
[Unit]
Description=Zammad rails server
Description=Zammad webserver
After=syslog.target
After=network.target
After={{ zammad_service }}
Requires={{ zammad_service }}
StartLimitIntervalSec=6
StartLimitBurst=10
[Service]
#Type=notify

View file

@ -6,6 +6,8 @@ After=syslog.target
After=network.target
After={{ zammad_service }}
Requires={{ zammad_service }}
StartLimitIntervalSec=6
StartLimitBurst=10
[Service]
EnvironmentFile={{ zammad_env_file }}

View file

@ -1,4 +1,4 @@
### {{ ansible_managed }}
{{ ansible_managed | comment }}
[Unit]
Description=Zammad Background Worker
@ -6,6 +6,8 @@ After=syslog.target
After=network.target
After={{ zammad_service }}
Requires={{ zammad_service }}
StartLimitIntervalSec=6
StartLimitBurst=10
[Service]
EnvironmentFile={{ zammad_env_file }}

View file

@ -11,7 +11,7 @@ Wants={{ zammad_websocket_service }}
EnvironmentFile={{ zammad_env_file }}
User={{ zammad_user }}
Group={{ zammad_user }}
Restart=always
Restart=on-failure
ExecStart=/bin/sleep infinity
[Install]

View file

@ -6,11 +6,6 @@ set -eu
RUBY_VERSION=$(cat {{ zammad_home }}/.ruby-version)
RUBY_INSTALLED_VERSIONS=$(rbenv version | grep $RUBY_VERSION | cut -d ' ' -f2)
echo "Stoppe Monit-Monitoring..."
monit unmonitor {{ zammad_websocket_service | splitext | first }}
monit unmonitor {{ zammad_rails_service | splitext | first }}
monit unmonitor {{ zammad_worker_service | splitext | first }}
echo "Wechsle Verzeichnis..."
cd {{ zammad_home }}
@ -48,9 +43,4 @@ echo "Starte Zammad..."
systemctl start {{ zammad_service }}
sleep 20
echo "Starte Monit-Monitoring..."
monit monitor {{ zammad_websocket_service | splitext | first }}
monit monitor {{ zammad_rails_service | splitext | first }}
monit monitor {{ zammad_worker_service | splitext | first }}
echo "Alles erledigt."