[asterisk-users] Pbx_lua vs. calling lua thru AGI?

Steve Edwards asterisk.org at sedwards.com
Wed Jun 30 19:01:50 CDT 2010


On Thu, 1 Jul 2010, Gilles wrote:

> I'm taking a look at how to write scripts to be called from the 
> dialplan, and saw pbx_lua mentioned.
>
> I'd like to know more about this feature, such as what the difference is 
> with just calling the Lua interpreter through AGI (same difference as 
> between php-cgi and mod_php?), whether it's production-ready, etc.

I've never used it (I'm a 1.2 Luddite), but I would be very interested in 
anything that looks like a "real" language for writing dialplans.

I've used AEL, and it is a much "cleaner" method of writing dialplan, but 
(at least in 1.2) it has a bunch of syntactical weirdness. For example, 
forgetting to end a line with a semi-colon can cause half your dialplan to 
disappear without warning.

I use AGI a lot. I write AGIs in C so, aside from the "create a new 
process" hit, they execute at the same speed as the code inside Asterisk. 
You can execute XXX AGIs written in C in the time it takes to load either 
the Perl or PHP interpreter and parse your script.

AGIs have a lot of advantages:

) If they crash, they only impact the call that invoked the AGI.

) They're nice little "black boxes" where you can package up a bunch of 
logic and complexity in a single line of dialplan. Imagine implementing 
voicemail in dialplan versus an AGI. AGIs hide a lot of detail and help 
keep clumsy fingers from introducing impossible to find bugs.

) They can be debugged separately from Asterisk. By feeding the 
appropriate input (by file redirection) from the command line, you can do 
a substantial bit of debugging as long as it doesn't need to actually 
interact with Asterisk. I frequently fire up emacs, load gdb, and step 
through my C AGIs line by line. Set a breakpoint, examine a variable, 
change it's value, and continue. Sure beats the heck out of trying to 
debug an AGI by peppering it with VERBOSE or syslog() statements.

-- 
Thanks in advance,
-------------------------------------------------------------------------
Steve Edwards       sedwards at sedwards.com      Voice: +1-760-468-3867 PST
Newline                                              Fax: +1-760-731-3000



More information about the asterisk-users mailing list