Activating FastAGI: Difference between revisions

From MiRTA PBX documentation
Jump to navigation Jump to search
No edit summary
 
(4 intermediate revisions by the same user not shown)
Line 2: Line 2:


== install node ==
== install node ==
On CentOS 6/7


<pre>
<pre>
curl -sL https://rpm.nodesource.com/setup_14.x | sudo bash -
curl -sL https://rpm.nodesource.com/setup_14.x | sudo bash -
sudo yum install -y nodejs
sudo yum install -y nodejs
npm install -g npm
</pre>
On CentOS 9
<pre>
yum install https://rpm.nodesource.com/pub_20.x/nodistro/repo/nodesource-release-nodistro-1.noarch.rpm -y
yum install nodejs -y
npm install -g npm
npm install -g npm
</pre>
</pre>
Line 50: Line 60:


npm i -g pm2
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:
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:
Line 58: Line 70:


You need to reload AEL only the first time
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

Latest revision as of 13:00, 8 March 2024

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

On CentOS 6/7

curl -sL https://rpm.nodesource.com/setup_14.x | sudo bash -
sudo yum install -y nodejs
npm install -g npm

On CentOS 9

yum install https://rpm.nodesource.com/pub_20.x/nodistro/repo/nodesource-release-nodistro-1.noarch.rpm -y
yum install nodejs -y
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