[SR-Users] Possibility of kemi lua to keep lua global vars

Yuriy Gorlichenko ovoshlook at gmail.com
Wed Apr 25 07:15:41 CEST 2018


Hi
For now as I see:  every request that calls lua script reevables my global
lua variables

For example

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?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-users/attachments/20180425/ab92773f/attachment.html>


More information about the sr-users mailing list