Use systemd to "monitor" and restart the service
This commit is contained in:
parent
6c6227919d
commit
d60c4d99b9
5 changed files with 13 additions and 25 deletions
4
files/systemd/override.conf
Normal file
4
files/systemd/override.conf
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
## Managed by Ansible
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Restart=always
|
|
@ -18,7 +18,3 @@
|
||||||
- name: User tasks
|
- name: User tasks
|
||||||
ansible.builtin.import_tasks: user.yml
|
ansible.builtin.import_tasks: user.yml
|
||||||
tags: never, user
|
tags: never, user
|
||||||
|
|
||||||
- name: Monitoring tasks
|
|
||||||
ansible.builtin.import_tasks: monitoring.yml
|
|
||||||
tags: monitoring
|
|
||||||
|
|
|
@ -1,8 +0,0 @@
|
||||||
---
|
|
||||||
- name: "Monitoring | Enable Monit monitoring"
|
|
||||||
ansible.builtin.template:
|
|
||||||
src: monit.j2
|
|
||||||
dest: /etc/monit/conf-enabled/phpfpm
|
|
||||||
mode: "0644"
|
|
||||||
when: '"monit" in ansible_facts.packages'
|
|
||||||
notify: reload monit
|
|
|
@ -37,3 +37,12 @@
|
||||||
path: /etc/systemd/system/php-fpm@.service.d
|
path: /etc/systemd/system/php-fpm@.service.d
|
||||||
state: directory
|
state: directory
|
||||||
mode: "0755"
|
mode: "0755"
|
||||||
|
|
||||||
|
- name: "PHP | Copy systemd override configuration"
|
||||||
|
ansible.builtin.copy:
|
||||||
|
src: systemd/override.conf
|
||||||
|
dest: /etc/systemd/system/php-fpm@.service.d/override.conf
|
||||||
|
mode: "0644"
|
||||||
|
notify:
|
||||||
|
- stop php-fpm-service
|
||||||
|
- start php-fpm-socket
|
||||||
|
|
|
@ -1,13 +0,0 @@
|
||||||
# {{ ansible_managed }}
|
|
||||||
|
|
||||||
check process php-fpm with pidfile /run/php/php{{ php_version.stdout }}-fpm.pid
|
|
||||||
group webserver
|
|
||||||
start program = "/usr/sbin/service php{{ php_version.stdout }}-fpm start"
|
|
||||||
stop program = "/usr/sbin/service php{{ php_version.stdout }}-fpm stop"
|
|
||||||
if failed unixsocket /run/php/php{{ php_version.stdout }}-fpm.sock for 3 cycles then restart
|
|
||||||
if 3 restarts within 5 cycles then timeout
|
|
||||||
|
|
||||||
{% if "apache2" in ansible_facts.packages %}
|
|
||||||
check file basedir with path /var/log/apache2/error.log
|
|
||||||
if match "open_basedir restriction in effect" then alert
|
|
||||||
{% endif %}
|
|
Loading…
Reference in a new issue