Manages status/ping path in FPM pools

freebsd
Emilien Mantel 2017-11-22 17:02:51 +01:00
parent de41097cde
commit df8b58b46a
3 changed files with 67 additions and 5 deletions

View File

@ -231,7 +231,11 @@ pm.max_spare_servers = {{ item.pm_max_spare_servers }}
; anything, but it may not be a good idea to use the .php extension or it
; may conflict with a real PHP file.
; Default Value: not set
;pm.status_path = /status
{% if item.status_path is defined %}
pm.status_path = {{ item.status_path }}
{% else %}
;pm.status.path = /status
{% endif %}
; The ping URI to call the monitoring page of FPM. If this value is not set, no
; URI will be recognized as a ping page. This could be used to test from outside
@ -243,12 +247,20 @@ pm.max_spare_servers = {{ item.pm_max_spare_servers }}
; anything, but it may not be a good idea to use the .php extension or it
; may conflict with a real PHP file.
; Default Value: not set
{% if item.ping_path is defined %}
ping.path = {{ item.ping_path }}
{% else %}
;ping.path = /ping
{% endif %}
; This directive may be used to customize the response of a ping request. The
; response is formatted as text/plain with a 200 response code.
; Default Value: pong
{% if item.ping_response is defined %}
ping.response = {{ item.ping_response }}
{% else %}
;ping.response = pong
{% endif %}
; The access log file
; Default: not set

View File

@ -0,0 +1,23 @@
server {
server_name {{ vhost }};
root /var/www;
{% if php_fpm_poold.0.status_path is defined %}
location = {{ php_fpm_poold.0.status_path }} {
include {{ nginx_include }};
fastcgi_pass unix:{{ php_default_fpm_sock }};
}
{% endif %}
{% if php_fpm_poold.0.ping_path is defined %}
location = {{ php_fpm_poold.0.ping_path }} {
include {{ nginx_include }};
fastcgi_pass unix:{{ php_default_fpm_sock }};
}
{% endif %}
location ~ \.php$ {
include {{ nginx_include }};
fastcgi_pass unix:{{ php_default_fpm_sock }};
}
}

View File

@ -10,6 +10,17 @@
display_errors: 'Off'
php_ini_cli:
error_reporting: 'E_ALL'
php_fpm_poold:
- pool_name: 'www'
listen: '{{ php_default_fpm_sock }}'
pm: 'dynamic'
pm_max_children: 250
pm_start_servers: 10
pm_min_spare_servers: 10
pm_max_spare_servers: 20
status_path: '/status'
ping_path: '/ping'
ping_response: 'ok'
pre_tasks:
@ -45,10 +56,16 @@
tasks:
- name: COPY | Vhost
copy: >
dest=/etc/nginx/sites-enabled/{{ vhost }}
content='server { server_name {{ vhost }}; root /var/www; location ~ \.php$ { include {{ nginx_include }}; fastcgi_pass unix:{{ php_default_fpm_sock }}; } }'
- name: TEMPLATE | Nginx site config
template:
src: templates/site.j2
dest: /etc/nginx/sites-enabled/{{ vhost }}
notify: reload nginx
- name: FILE | Delete default site
file:
path: /etc/nginx/sites-enabled/default
state: absent
notify: reload nginx
handlers:
@ -80,3 +97,13 @@
changed_when: false
register: c
failed_when: c.stdout == ''
- name: URI | Check ping
uri:
url: "http://localhost{{ php_fpm_poold.0.ping_path }}"
when: php_fpm_poold.0.ping_path is defined
- name: URI | Check status
uri:
url: "http://localhost{{ php_fpm_poold.0.status_path }}"
when: php_fpm_poold.0.status_path is defined