Activating FastAGI: Difference between revisions
(Created page with "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. To configure the FastAGI please follow this or any other guide on the Internet: https://fire-tamarillo-3f6.notion.site/nodejs-fastagi-server-266693b14a1748fb93a596265691fc38 On the MiRTA PBX side, you can edit the extensions.ael and uncomment the row at top, in globals section...") |
No edit summary |
||
(7 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
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. | 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 | |||
<pre> | |||
curl -sL https://rpm.nodesource.com/setup_14.x | sudo bash - | |||
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 | |||
</pre> | |||
== install pm2 == | |||
<pre> | |||
sudo npm i -g pm2 | |||
</pre> | |||
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 == | |||
<pre> | |||
pm2 startup | |||
pm2 install pm2-logrotate | |||
</pre> | |||
== start fast agi script with pm2 == | |||
<pre> | |||
pm2 start /var/lib/asterisk/agi-bin/node/fastagi-server.js | |||
pm2 save | |||
pm2 list | |||
pm2 update | |||
</pre> | |||
fastagi-server.js (--watch) don't use watch it reloads for all files in the path | |||
== centos 6 == | |||
<pre> | |||
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) | |||
</pre> | |||
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: | 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 12: | 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