1
0
Fork 0
mirror of https://github.com/iiab/iiab.git synced 2025-02-14 20:22:08 +00:00

Contextualize @jvonau's fpm-asterisk PR #2930, for FreePBX on NGINX

This commit is contained in:
root 2021-08-10 08:11:09 -04:00
parent 9e056923e1
commit 4caebbda90
6 changed files with 158 additions and 9 deletions

View file

@ -35,31 +35,31 @@
- block:
- name: Supply asterisk.conf to /etc/php/{{ php_version }}/fpm/pool.d/ with asterisk as the user
- name: Install /etc/php/{{ php_version }}/fpm/pool.d/asterisk.conf converted from www.conf for user 'asterisk', if pbx_enabled
copy:
src: roles/pbx/templates/asterisk.conf
dest: /etc/php/{{ php_version }}/fpm/pool.d/asterisk.conf
when: pbx_enabled
- name: Remove /etc/php/{{ php_version }}/fpm/pool.d/asterisk.conf when disabled
- name: Remove /etc/php/{{ php_version }}/fpm/pool.d/asterisk.conf, if not pbx_enabled
file:
path: /etc/php/{{ php_version }}/fpm/pool.d/asterisk.conf
state: absent
when: not pbx_enabled
- name: Restart 'php{{ php_version }}-fpm' systemd service
- name: Enable & Restart 'php{{ php_version }}-fpm' systemd service
systemd:
name: php{{ php_version }}-fpm
state: restarted
enabled: yes
- name: Enable http://box/freepbx via NGINX, by installing {{ nginx_conf_dir }}/freepbx-nginx.conf from template
- name: Enable http://box/freepbx via NGINX, by installing {{ nginx_conf_dir }}/freepbx-nginx.conf from template, if pbx_enabled
template:
src: freepbx-nginx.conf.j2
dest: "{{ nginx_conf_dir }}/freepbx-nginx.conf" # /etc/nginx/conf.d
when: pbx_enabled
- name: Disable http://box/freepbx via NGINX, by removing {{ nginx_conf_dir }}/freepbx-nginx.conf
- name: Disable http://box/freepbx via NGINX, by removing {{ nginx_conf_dir }}/freepbx-nginx.conf, if not pbx_enabled
file:
path: "{{ nginx_conf_dir }}/freepbx-nginx.conf"
state: absent

View file

@ -180,8 +180,8 @@
command: "{{ item }}"
with_items:
- fwconsole stop
- killall -9 "PM2 v4.5.0: God" # 2021-08-09 might be missed by fwconsole
- killall -9 safe_asterisk # 2021-08-08: Stronger medicine needed for 64-bit Ubuntu Server 21.04 on RPi 4. Originally from @jvonau's PR #2912.
- killall -9 safe_asterisk # 2021-08-08: Stronger medicine needed for 64-bit Ubuntu Server 21.04 on RPi 4. Originally from @jvonau's PR #2912.
- killall -9 "PM2 v4.5.0: God" # 2021-08-09: Missed by fwconsole (does this matter?)
# - killall -9 asterisk # 2021-08-05: Also from @jvonau's PR #2912, to brute force this. In the end, above 'fwconsole stop' works more gracefully.
# - ./start_asterisk stop # Buggy!
# - /usr/sbin/asterisk -rx "core stop gracefully"

View file

@ -1,3 +1,25 @@
; 2021-08-10: @jvonau derived this from /etc/php/7.4/fpm/pool.d/www.conf (apt
; package php7.4-fpm) with 4 core changes: (github.com/iiab/iiab/pull/2930)
;
; 1. [www] -> [asterisk]
; 2. user = www-data -> user = asterisk
; 3. listen = /run/php/php7.4-fpm.sock -> listen = /run/php/php-asterisk.sock
; 4. listen.owner = www-data -> listen.owner = asterisk
;
; See also asterisk.conf.patch and asterisk.conf.diff here:
; https://github.com/iiab/iiab/tree/master/roles/pbx/templates
;
; "One set of workers is running as www-data and the other set of workers is
; running as asterisk but on different sockets."
;
; This should resolve both iiab/iiab#2914 -> iiab/iiab#2916 "NGINX" issues:
; (1) As you tried to register at http://box/freepbx, cron setup failed with
; exception "Trying to edit user asterisk, when I'm running as www-data"
; https://github.com/iiab/iiab/pull/2916#issuecomment-894585322
; (2) When you clicked Settings >> Advanced Settings >> Submit >> Apply Config,
; it failed with "Unknown Error. Please Run: fwconsole reload --verbose"
; https://github.com/iiab/iiab/pull/2916#issuecomment-894604982
; Start a new pool named 'www'.
; the variable $pool can be used in any directive and will be replaced by the
; pool name ('www' here)

View file

@ -0,0 +1,40 @@
4c4
< [www]
---
> [asterisk]
23c23
< user = www-data
---
> user = asterisk
36c36
< listen = /run/php/php7.4-fpm.sock
---
> listen = /run/php/php-asterisk.sock
48c48
< listen.owner = www-data
---
> listen.owner = asterisk
114c114,115
< pm.max_children = 5
---
> ;pm.max_children = 5
> pm.max_children=120
119c120,121
< pm.start_servers = 2
---
> ;pm.start_servers = 2
> pm.start_servers=12
124c126,127
< pm.min_spare_servers = 1
---
> ;pm.min_spare_servers = 1
> pm.min_spare_servers=6
129c132,133
< pm.max_spare_servers = 3
---
> ;pm.max_spare_servers = 3
> pm.max_spare_servers=18
397a402
> clear_env = no
411a417
> env[PATH]=/usr/local/bin:/usr/bin:/bin

View file

@ -0,0 +1,85 @@
--- /etc/php/7.4/fpm/pool.d/www.conf 2021-07-01 23:59:48.000000000 -0400
+++ /etc/php/7.4/fpm/pool.d/asterisk.conf 2021-08-10 05:25:09.808067373 -0400
@@ -1,7 +1,7 @@
; Start a new pool named 'www'.
; the variable $pool can be used in any directive and will be replaced by the
; pool name ('www' here)
-[www]
+[asterisk]
; Per pool prefix
; It only applies on the following directives:
@@ -20,7 +20,7 @@
; Unix user/group of processes
; Note: The user is mandatory. If the group is not set, the default user's group
; will be used.
-user = www-data
+user = asterisk
group = www-data
; The address on which to accept FastCGI requests.
@@ -33,7 +33,7 @@
; (IPv6 and IPv4-mapped) on a specific port;
; '/path/to/unix/socket' - to listen on a unix socket.
; Note: This value is mandatory.
-listen = /run/php/php7.4-fpm.sock
+listen = /run/php/php-asterisk.sock
; Set listen(2) backlog.
; Default Value: 511 (-1 on FreeBSD and OpenBSD)
@@ -45,7 +45,7 @@
; and group can be specified either by name or by their numeric IDs.
; Default Values: user and group are set as the running user
; mode is set to 0660
-listen.owner = www-data
+listen.owner = asterisk
listen.group = www-data
;listen.mode = 0660
; When POSIX Access Control Lists are supported you can set them using
@@ -111,22 +111,26 @@
; forget to tweak pm.* to fit your needs.
; Note: Used when pm is set to 'static', 'dynamic' or 'ondemand'
; Note: This value is mandatory.
-pm.max_children = 5
+;pm.max_children = 5
+pm.max_children=120
; The number of child processes created on startup.
; Note: Used only when pm is set to 'dynamic'
; Default Value: (min_spare_servers + max_spare_servers) / 2
-pm.start_servers = 2
+;pm.start_servers = 2
+pm.start_servers=12
; The desired minimum number of idle server processes.
; Note: Used only when pm is set to 'dynamic'
; Note: Mandatory when pm is set to 'dynamic'
-pm.min_spare_servers = 1
+;pm.min_spare_servers = 1
+pm.min_spare_servers=6
; The desired maximum number of idle server processes.
; Note: Used only when pm is set to 'dynamic'
; Note: Mandatory when pm is set to 'dynamic'
-pm.max_spare_servers = 3
+;pm.max_spare_servers = 3
+pm.max_spare_servers=18
; The number of seconds after which an idle process will be killed.
; Note: Used only when pm is set to 'ondemand'
@@ -395,6 +399,7 @@
; via getenv(), $_ENV and $_SERVER.
; Default Value: yes
;clear_env = no
+clear_env = no
; Limits the extensions of the main script FPM will allow to parse. This can
; prevent configuration mistakes on the web server side. You should only limit
@@ -409,6 +414,7 @@
; Default Value: clean env
;env[HOSTNAME] = $HOSTNAME
;env[PATH] = /usr/local/bin:/usr/bin:/bin
+env[PATH]=/usr/local/bin:/usr/bin:/bin
;env[TMP] = /tmp
;env[TMPDIR] = /tmp
;env[TEMP] = /tmp

View file

@ -8,8 +8,10 @@ RemainAfterExit=yes
ExecStart=/usr/sbin/fwconsole start
ExecStop=/usr/sbin/fwconsole stop
ExecStopPost=killall -9 "PM2 v4.5.0: God"
# 2021-08-04: Asterisk doesn't (re)start reliably, as FreePBX install completes,
# especially on Debian 11? https://github.com/iiab/iiab/pull/2908 / PR #2910
# 2021-08-10: Asterisk stuff doesn't stop reliably, right after freepbx.yml
# 'install -n' completes -- hence "Unable to run Pre-Asterisk hooks, because
# Asterisk is already running" issue when freepbx.service next tries to start
# it. See pbx/tasks/freepbx.yml workarounds e.g. github.com/iiab/iiab/pull/2915
[Install]
WantedBy=multi-user.target