Hey @miken32 ,
Wanted to comment on this briefly. The reason nodejs was chosen way back in the day was because we needed a non-blocking daemon to service real time events for UCP (which was contained in the ucpnode module). At the time PHP was not performant in real-time non blocking performance areas (I dont think it really fits that well even today, you can’t make mysql or file operations in PHP that aren’t blocking and you can’t make non-blocking http requests nicely without a library like guzzle and guzzle only has async on php 5.6+).
Furthermore. When it comes to pm2 (which is a nodejs process manager). At the time there were no good PHP process managers that supported PHP 5.3 (there are some good ones for php 7.2+ though), there still aren’t because PHP 5.3 is dead. But that’s what FreePBX 13 supports so you end up stuck in a way.
Using nodejs in the first place was never a performance concern in regards to PHP. It was allowing daemons to be written in a language that is non-blocking. As I said before, PHP is a blocking language it was never written as non-blocking in mind (and still isnt even in 8). Though I don’t work on FreePBX anymore I doubt it would move entirely to NodeJS, that was never the goal and never even a thought. NodeJS was just for daemons that need to be non-blocking (Like Zulu, UCP and pm2 (which manages some php processes as well)).
NodeJS was also used in FreePBX 13 for many things. But we wanted to give our work back to the community. So we released pm2 in 13+ and released ucpnode inside of ucp in 14, that’s probably where some of your headaches come in and I’m sorry for that :(. Unforutnately there was no way to write a performant realtime UCP application without nodejs (yes it could have probably been done in python but you are back at the original problem, another language that isn’t FreePBX’s base.. so does that really solve anything? Furthermore CentOS is still on some Python 2.x version, you can’t load in Python 3.x without causing all sorts of headaches (because CentOS 5-7 uses Python in yum) so the code, if written in Python would have to have been done in Python 2)). FreePBX needed a centralized process manager.
Additionally, as I talked about in a previous blog (Performance Improvements in FreePBX). There is another nodejs process in Core (which is extremely lightweight) that launches the older FreePBX AGIs through a FastAGI proxy (this is optional but gives FreePBX a huge performance boost). There’s a thread on twitter where I explained this at length for @mattf and someone from Issabel if you want to take a look.
https://twitter.com/tm1000/status/1197604435104391168
Anyways hope that helps clear that up (and remember I’m just an outsider)
Finally. It’s worth noting that the Sangoma team in place now is highly skilled in NodeJS, they use and maintain one of their most active repositories on github which is the NodeJS ARI SDK.
And if you didn’t know one of @mattf’s previous roles at Sangoma was working on the product Respooke which was also written in NodeJS.
I don’t want this to sound like a round of excuses, just thought perhaps the context of why things were done the way they were done would be helpful and to let you know that this wasn’t a “short-sighted decision”. No project is ever going to get 100% of things right 100% of the time but it’s good for the community to know why things were done and at the time we (I?) should have been more transparent about why NodeJS was chosen.
Also wanted to give another shoutout to @miken32 who was (is?) the most active outside contributor in terms of code to FreePBX. You are one of the reasons that makes this community so great!