I trying to connect to DB via luasql driver and checking if connection already existis to avoid new connection
I have function init() that calls in ksr_request_route()
Inside i have ome check:
if not CON then
CON = assert(MYSQL:connect(DBdata.dbname,DBdata.username,DBdata.password,DBdata.host,DBdata.port))
if not CON then
KSR.log("info","|init|log| DB NOT connected\n")
KSR.sl.sl_send_reply(503,"Internal server error")
KSR.x.exit()
else
KSR.log("info","|init|log| DB connected\n")
end
end
So in this case if CON was already created it should not try to connect
But for now it tries for every request. So means kemi not stores global lua variables between sessions (in one kamailio process)
Also as I know INIT routes initiates before lua machine will be started so it not allowed to init some lua global variables in the init routes
So my question is there is a way to keep global vars per kamailio process instead per kamailio request?