Activating FastAGI
With very busy servers, it can help to offload the AGI scripts to another server or process. The load is reduced because there is no need to spawn a process every time a new AGI script is run.
install node
curl -sL https://rpm.nodesource.com/setup_14.x | sudo bash - sudo yum install -y nodejs npm install -g npm
install pm2
sudo npm i -g pm2
Copy the whole node folder
https://git.freepbx.org/projects/FREEPBX/repos/core/browse/node
to /var/lib/asterisk/agi-bin directory
run pm2 at start up
pm2 startup pm2 install pm2-logrotate
start fast agi script with pm2
pm2 start /var/lib/asterisk/agi-bin/node/fastagi-server.js pm2 save pm2 list pm2 update
fastagi-server.js (--watch) don't use watch it reloads for all files in the path
centos 6
cd ~ wget http://nodejs.org/dist/v10.15.1/node-v10.15.1-linux-x64.tar.gz # (Must check the latest version change the version name accordingly) sudo tar --strip-components 1 -xzvf node-v10.15.1-linux-x64.tar.gz -C /usr/local # (Must check the latest version change the version name accordingly)
Verify by using: node --version
npm i -g pm2
Final setting
On the MiRTA PBX side, you can edit the extensions.ael and uncomment the row at top, in globals section (but this change will be overwritten at every upgrade) or add a file in /etc/asterisk/extensions.d named for example fastagi.ael and containing:
globals { FASTAGI=agi://127.0.0.1/; };
You need to reload AEL only the first time
Patching fastagi
It seems there is a bug in the current fastagi-server.js. It tries to split the parameters with the ":", but that is breaking the date when uploading the recordings.
Replace the line:
let s = line.split(":").map((item) => {
With
let s = line.split(": ").map((item) => {
Once patched, you need to run
pm2 reload fastagi-server