php socket activation
This commit is contained in:
parent
9dffeb8646
commit
46c8dfe23b
5
roles/php/files/php-fpm-stop.service
Normal file
5
roles/php/files/php-fpm-stop.service
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
[Unit]
|
||||||
|
Description="Stop php-fpm"
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
ExecStart=/usr/local/bin/stop-php-fpm
|
10
roles/php/files/php-fpm-stop.timer
Normal file
10
roles/php/files/php-fpm-stop.timer
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Stop php-fpm
|
||||||
|
|
||||||
|
[Timer]
|
||||||
|
OnBootSec=2min
|
||||||
|
OnUnitActiveSec=2min
|
||||||
|
Persistent=true
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
11
roles/php/files/php-fpm.service
Normal file
11
roles/php/files/php-fpm.service
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=The PHP FastCGI Process Manager
|
||||||
|
After=syslog.target network.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=notify
|
||||||
|
PIDFile=/run/php-fpm/php-fpm.pid
|
||||||
|
PrivateTmp=true
|
||||||
|
Environment="FPM_SOCKETS=/var/run/php-fpm.socket=3"
|
||||||
|
ExecStart=/usr/bin/php-fpm --nodaemonize --pid /run/php-fpm/php-fpm.pid
|
||||||
|
ExecReload=/bin/kill -USR2 $MAINPID
|
5
roles/php/files/php-fpm.socket
Normal file
5
roles/php/files/php-fpm.socket
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
[Socket]
|
||||||
|
ListenStream=9000
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=sockets.target
|
8
roles/php/files/stop-php-fpm
Normal file
8
roles/php/files/stop-php-fpm
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
PID=$(cat /run/php-fpm/php-fpm.pid)
|
||||||
|
CHILDREN=$(ps -o pid --no-headers --ppid "$PID" | wc -l)
|
||||||
|
|
||||||
|
if [ $CHILDREN == "0" ]; then
|
||||||
|
kill "$PID"
|
||||||
|
fi
|
@ -1,2 +1,4 @@
|
|||||||
- name: restart php-fpm
|
- name: stop php-fpm
|
||||||
service: name=php-fpm state=restarted
|
service: name=php-fpm state=restarted
|
||||||
|
- name: Reload systemd
|
||||||
|
action: command systemctl daemon-reload
|
||||||
|
@ -1,10 +1,27 @@
|
|||||||
- name: install php-fpm
|
- name: install php-fpm
|
||||||
pacman: name=php-fpm state=present
|
pacman: name=php-fpm state=present
|
||||||
- name: Enable php-fpm
|
|
||||||
service: name=php-fpm state=started enabled=yes
|
|
||||||
- name: php-fpm.ini
|
- name: php-fpm.ini
|
||||||
template: src=php-fpm.conf.j2 dest=/etc/php/php-fpm.conf mode=0644 backup=yes
|
template: src=php-fpm.conf.j2 dest=/etc/php/php-fpm.conf mode=0644 backup=yes
|
||||||
notify: restart php-fpm
|
notify: stop php-fpm
|
||||||
- name: php.ini
|
- name: php.ini
|
||||||
template: src=php.ini.j2 dest=/etc/php/php.ini mode=0644 backup=yes
|
template: src=php.ini.j2 dest=/etc/php/php.ini mode=0644 backup=yes
|
||||||
notify: restart php-fpm
|
notify: stop php-fpm
|
||||||
|
- copy: src={{ item }} dest=/etc/systemd/system/{{ item }} mode=0644
|
||||||
|
with_items:
|
||||||
|
- php-fpm.service
|
||||||
|
- php-fpm.socket
|
||||||
|
- php-fpm-stop.timer
|
||||||
|
- php-fpm-stop.service
|
||||||
|
notify: Reload systemd
|
||||||
|
- copy: src=stop-php-fpm dest=/usr/local/bin/stop-php-fpm mode=0755
|
||||||
|
- shell: /usr/bin/systemctl --quiet is-active php-fpm.socket
|
||||||
|
register: fpm_socket_started
|
||||||
|
ignore_errors: True
|
||||||
|
- name: Stop php-fpm
|
||||||
|
service: name=php-fpm.service state=stopped
|
||||||
|
when: fpm_socket_started.rc != 0
|
||||||
|
- name: Start php-fpm socket activation
|
||||||
|
service: name={{item}} state=started enabled=yes
|
||||||
|
with_items:
|
||||||
|
- php-fpm.socket
|
||||||
|
- php-fpm-stop.timer
|
||||||
|
@ -158,7 +158,7 @@ group = http
|
|||||||
; specific port;
|
; specific port;
|
||||||
; '/path/to/unix/socket' - to listen on a unix socket.
|
; '/path/to/unix/socket' - to listen on a unix socket.
|
||||||
; Note: This value is mandatory.
|
; Note: This value is mandatory.
|
||||||
listen = 0.0.0.0:9000
|
listen = /var/run/php-fpm.socket ; pseudo socket, will no be used really
|
||||||
|
|
||||||
; Set listen(2) backlog.
|
; Set listen(2) backlog.
|
||||||
; Default Value: 65535 (-1 on FreeBSD and OpenBSD)
|
; Default Value: 65535 (-1 on FreeBSD and OpenBSD)
|
||||||
|
Loading…
Reference in New Issue
Block a user