如何将现有Asterisk AGI脚本转换为FASTAGI脚本


How to Convert existing Asterisk AGI scripts to FASTAGI script

我有一台Asterisk服务器,在支付环境中运行良好。现在,我需要将业务逻辑与Asterisk Server分离,以提高效率,并出于显而易见的原因保护AGI脚本。

问题是,如何将现有的工作AGI脚本转换为FASTAGI脚本,或者如何从FASTAGI服务器调用现有的AGI脚本?

我在这个平台上发布了一些带有答案的帖子,但没有人明确说明如何从头开始。很高兴能清楚地了解如何使用PHP实现这一点。

您可以为此使用xinetd。从每个星号框上的拨号计划中,用快速agi参数调用agi,替换您的快速agi服务器的IP地址:

AGI(agi://192.168.1.100/)

确保你在/etc/services中有类似的东西:

agi             4573/tcp                        # FAST AGI entry

在FastAGI服务器上:在一个名为/etc/xinetd.d/agi的文件中(确保/etc/xinetd.conf正在从/etc/xinetd.d/加载模块)有一个调用agi脚本的定义。

# description: agi service for PHP fastagi interaction
service agi
{
        socket_type  = stream
        user         = root
        group        = nobody
        server       = /path/to/agiLaunch.sh
        wait         = no
        protocol     = tcp
        bind         = 127.0.0.1
        disable      = no
        per_source   = UNLIMITED
        instances    = UNLIMITED
        cps          = 1000 0
}

在AGI脚本中,您现在可以像往常一样读取STDIN或STDOUT。