Agispeedy

Agispeedy Be Part of Freeiris. 中文版

DESCRIPTION

The Agispeedy is robust implemention of AGI in asterisk. Agispeedy is inconceivable faster than AGI. The result of test shows that by using Agispeedy in asterisk, the performance of system would be improved more than 10 times comparing with AGI.

Agispeedy Features:

  • 2011-5-9 Support Asterisk 1.8.X AGI args syntax not support 1.4.X
  • implemention of AGI(FastAGI) over TCP Sockets
  • Work in Stabilize Prefork Mode and Written by Pure Perl.
  • Easy to Maintain, unlike FastAGI(Dynamic Load AGI no need restart Agispeedy services)
  • Providing possibility of running AGI on a remote server(Inheriting the FastAGI)
  • Fast Database Connect(system can hook database connection in child process)

Table of asterisk extend tech:

name speed reliability cluster
asterisk module top faster easy crash no
agi slowly strong no
fastagi faster maybe crash yes
agispeedy faster strong yes

SYNOPSIS

/agispeedy/bin/agispeedy --verbose
[Fri May 21 19:24:15 2010] Agispeedy 2.0 services on...
[Fri May 21 19:24:15 2010] Loading static : demo_static
[Fri May 21 19:24:15 2010] 2010/05/21-19:24:15 main (type Net::Server::PreFork) starting! pid(32528)
[Fri May 21 19:24:15 2010] Binding to TCP port 4573 on host *
[Fri May 21 19:24:15 2010] Setting gid to "0 0"
[Fri May 21 19:24:15 2010] Setting up serialization via flock
[Fri May 21 19:24:15 2010] Beginning prefork (6 processes)
[Fri May 21 19:24:15 2010] Starting "6" children

GUIDE

Get Agispeedy

get source files from SVN:
>svn export http://darwin.freeiris.org/svn/freeiris/addition/agispeedy/

Installation

Under the agispeedy, install agispeedy by run the script: ./install.pl You also can add -–prefix=path to other directory, for example, you can add agispeedy to system boot by copying contrib/agispeedy.init.centos to /etc/init.d/

please note: sudo as root

>cd agispeedy
>chmod +x install.pl
>./install.pl

  [RESPONSE] Agispeedy Installer
    [INPUT] continue to install agispeedy to /agispeedy (yes/no)?yes
......
  [RESPONSE] set /etc/agispeedy
  [RESPONSE] set agispeedy services

Command Line

More parameters to run AGIspeedy:

  • -?, –help Display this help and exit.
  • -V, –version Output version information and exit.
  • -v, –verbose Display more messages on screen(debug level 4).
  • -q, –quiet Start Agispeedy as background.
  • -c, –config=path Specify Config files directory.
  • -L, –log=path Specify Log files directory.
  • -l, –lib=lib Specify Agispeedy include directory.
  • -P, –pid=path Specify pid file directory.
  • -a, –var=path Specify Agispeedy script modules directory.

run DEBUG mode:

./agispeedy –verbose

will output all messages from agispeedy services

Run Normal Commandline:

./agispeedy –quiet

agispeedy will quiet and slience run in background and write messages to log_files.

run Services:

/etc/init.d/agispeedy start

If you are not use redhat, you have to manually install init scripts.

checking process:

>ps ax|grep agispeedy
32424 ?        Ss     0:00 /usr/bin/perl /agispeedy/bin/agispeedy -q -c /etc/agispeedy
32425 ?        S      0:00 /usr/bin/perl /agispeedy/bin/agispeedy -q -c /etc/agispeedy
32426 ?        S      0:00 /usr/bin/perl /agispeedy/bin/agispeedy -q -c /etc/agispeedy
32427 ?        S      0:00 /usr/bin/perl /agispeedy/bin/agispeedy -q -c /etc/agispeedy
32428 ?        S      0:00 /usr/bin/perl /agispeedy/bin/agispeedy -q -c /etc/agispeedy
32430 ?        S      0:00 /usr/bin/perl /agispeedy/bin/agispeedy -q -c /etc/agispeedy
32431 ?        S      0:00 /usr/bin/perl /agispeedy/bin/agispeedy -q -c /etc/agispeedy

Quickly demo

folder structure:

  • /agispeedy/ mainfolder
  • /agispeedy/var holding your agispeedy script modules
  • /agispeedy/log logs and pid file
  • /agispeedy/lib agispeedy self internal module, if your need advanced control agispeedy you need check this folder.
  • /agispeedy/etc agispeedy configure files
  • /agispeedy/bin agispeedy entry services

1) Please start agispeedy services.

edit extensions.conf in asterisk [default] add:

exten => 123456,1,NoOp('agispeedy demo')
exten => 123456,n,AGI(agi://127.0.0.1/demo_dynamic,number=7890,xxx=yyy)
exten => 123456,n,hangup

2) if the agispeedy does not be installed in the asterisk server, you have to change “127.0.0.1”.

3) Using a registered extension to dial 123456, you should hear the system play the digits “7890”.

agispeedy.conf

open agispeedy.conf from etc folder.

# this is agispeedy simple config file

[general]
etc_path=/etc/agispeedy/
bin_path=/agispeedy/bin/
pid_path=/agispeedy/log/
lib_path=/agispeedy/lib/
log_path=/agispeedy/log/
var_path=/agispeedy/var/

# runtime settings hook for your special request
[services]
# * means bind all ip
host=*
# 4573 is asterisk fastagi port please don't change
port=4573
# run agispeedy as user and group
user=
group=
# if you have performace cpu and memory you can modify followed sets
min_servers=6
min_spare_servers=2
max_spare_servers=12
max_servers=64
max_requests=512

[log]
# log file default yes/no and log level
enable=yes
# Set log level, Default 2 :
# 0 error,1 warnning,2 notice,3 info,4 debug
level=2

[agispeedymodules]
enable_dynamic=yes
# enable static will auto load module in agispeedy initilization time
enable_static=yes
# dynamic agispeedy module file extname
dynamic_ext=dam
# static agispeedy module file extname
static_ext=sam

Write Agispeedy Modules

Agispeedy Automatically responses user request from asterisk.

modules format

  • There are tow types in Agispeedy script modules:
    • static - saving in /agispeedy/var/ and extname is ”.sam”
      • modules will be autoloaded in agispeedy during starting time and not support reload until you restart agispeedy services
    • dynamic - saving in /agispeedy/var and extname is ”.dam”
      • Modules will be complied at user request time, dynamic is light and handy.

how does agispeedy work

example : 
exten => 123456,n,AGI(agi://127.0.0.1/demo_dynamic,number=7890,xxx=yyy)
  • asterisk send socket request scriptname demo_dynamic with args
  • agispeedy get one child to response asterisk
  • child find demo_dynamic static module in memory
  • child find demo_dynamic.dam in /agispeedy/var/
  • child do args parse and push to hash table
  • child synatx checking and complie demo_dynamic.dam
  • child run entry function demo_dynamic()
  • child exit

so if you need new function directly write your module in /agispeedy/var

new modules

Please note that name of entry function must be same with filename.

abc.sam's entry function named sub abc()

def.dam's entry function named sub def()

demo_dynamic.dam:
# write by somebody
use foo;  # your can write use module outside entry
sub demo
{
my $self = shift;
my $server_prop = $self->{server};
my $agi = $server_prop->{agi};
my $params = $agi->{params};

my $number = $self->_demo_count($params->{'number'});
    $agi->say_digits($number);

exit;
}
sub _demo_count
{
  return($_[0]);
}
  • $server_prop hash ref all server information include agi
  • $agi inherit from Asterisk::AGI
  • $params ref hash args from asterisk

Agispeedy Rule

  • Each module name is uniqued.
  • Declare variables affect on your sub and current child only.
  • $self hash ref from agispeedy child process.
  • %OPT, %STATIC_MODULES, @STATIC_MODULES_LIST registed global variables in each child.

FAQ

high-performance Mysql Connect

Agispeedy supports hooks, you can make database connection in child initial stage and it makes fast than request time.

edit /agispeedy/lib/agispeedy_hook.pm
sub child_init_hook()
{
     you can write database connect here.
     and register in to $self->{server}{dbh}.
     and recall dbh from your modules
}

in /agispeedy/var/demo.dam
sub demo
{
my $self = shift;
my $dbh = $self->{server}{dbh};
}

EXAMPLES

Freeiris2 Chinese Opensource Telelphony used Agispeedy replace all of agis

AUTHORS

COPYRIGHT

Copyright © 2009, Sun bing hoowa.sun@gmail.com.

Copyright © 2010, Fonoirs CO.,LTD.

You may distribute under the terms of either the GNU General Public License VERSION 2.

WARRANTY

The Agispeedy is free Open Source software.

IT COMES WITHOUT WARRANTY OF ANY KIND.

SUPPORT

Sangoma数字卡/模拟卡

数字卡/模拟语音卡
厂商: 北京开源方诺科技有限公司  编号:   质保: 60月  查看详细
 此产品为第三方赞助商向您推荐.
Freeiris爱好者QQ群  43185599
agispeedy.txt · Last modified: 2011/05/09 15:14 by hoowa
Copyright © 2010 Freeiris DevelopTeam All Rights Reserved