Hi all,
Is there a function I can use to test database connection from the routing script in the cfg file? My dispatcher uses OPTIONS probing. When the destination receives the OPTIONS request, I'd like to detect the health status of the database connection before sending a 200 back. Note the OPTIONS request doesn't have a user part in the RURI. Hence, is_subscriber() and alias_db_lookup() don't work.
Any suggestion?
Regards,
Allen Zhang
On Thursday 07 November 2013 05:31:58 Allen Zhang wrote:
Is there a function I can use to test database connection from the routing script in the cfg file? My dispatcher uses OPTIONS probing. When the destination receives the OPTIONS request, I'd like to detect the health status of the database connection before sending a 200 back.
Somewhere in the request_route just do a query with a known response and is the response matches the expected value return a 200 else something else (or nothing at all like below).
if(is_method("OPTIONS")) { sql_xquery("ca", "select unix_timestamp(now()) as t", "ra"); $var(ca)=$xavp(ra=>t); sql_result_free("ra");
if($(var(ca))>1) { sl_send_reply("200","Up and running"); } exit; }