Closed miken32 closed 6 years ago
Why not add that variable to the globals.conf file (along with the a2b stuff for mysql connection)
[globals] failover-a2bdead="SIP/${EXTEN}@sip_trunk,60,rL(3600000:61000:30000)" A2BDBHOST=mysqlip A2BDBUSER=a2dbuser A2BDBPASSWORD=a2bdbpassword A2BDBNAME=a2bdbname Then in extensions file add to teh a2billing context
[a2billing](somewhere in there, probably after manipulating dialed digits, before sending to Agi %28a2billing.hp,1%29) exten => _X.,n,MYSQL(Connect CONNID ${A2BDBHOST} ${A2BDBUSER} ${A2BDBPASSW} ${A2BDBNAME}) exten => _X.,n,MYSQL(Query RESULTID ${CONNID} SELECT something FROM table WHERE field = somelookup ) exten => _X.,n,GotoIf($["${MYSQL_STATUS}" = "-1"]?lbl_a2bdead:) exten => _X.,n,MYSQL(Clear ${RESULTID}) exten => _X.,n,(lbl_a2bdead), NoOp (A2B DB unreachable - switching to failover route) exten => _X.,n,(lbl_a2bdead), Dial(${failover-a2bdead});
Haven't edited dialplans manually in a while, so use with caution. Not sur how using a global that uses a variable will work here, may need to split the failover-a2bdead into two portions, or just use the portion after that ${EXTEN}...
As proposed in issue #119 this allows for a destination to be specified in
a2billing.conf
to be used in case of database failure. Sample entry in config file:We use A2Billing only for outbound postpaid billing, so this is the only case handled. Probably it doesn't make any sense to try this model for other methods, except maybe inbound DID which could be pointed to a backup extension on the system.
The change that needs testing is that
A2Billing::DbConnect()
has been modified to returnfalse
in case of failure, instead of dying. This seems like a better way of handling things to me, but there may be other locations in the code where this behaviour is not expected. In the AGI there was already a conditional block looking for a false return (which never would have been reached) that I hooked in to.