[sr-dev] Reloading lua script

Vicente Hernando vhernando at systemonenoc.com
Wed Apr 25 14:15:52 CEST 2012


Hello,

from a thread in sip-router user mailing list: 
http://lists.sip-router.org/pipermail/sr-users/2012-March/072657.html

This thread talks about reloading lua scripts in runtime context.

>>/  I'm starting to play with lua scripting in Kamailio. It's really cool,
/>>/  some complex stuff in the script becomes really easy this way. The
/>>/  script is becoming quite big, therefore I'd like to use lua_run
/>>/  instead of lua_dofile. My doubt is pretty  basic: if i load a script
/>>/  in memory at startup via the "load" parameter and the script is
/>>/  modifed afterwards, is there any way to reload the module so the
/>>/  script is reread?
/>the two contexts created by app_lua were designed one for loading at
>startup and the other for reloading every time. Reloading on demand at
>runtime is not possible. I thought of checking the timestamp of the
>script, but can be a bit risky if saving on intermediary state during
>updates. The scripts are loaded in each process, sending a mi/rpc
>command will require to do some inter-process signaling. Both doable,
>not in my short term plans, though, if someone is contributing, will be
>appreciated.


I have attached a test patch to start playing with this task.

A new function app_lua.runfile is created, and called via sercmd tool to 
load some lua script in runtime context.

Some signaling is needed so every kamailio child process would reload 
the script too.

Could you give some clues about performing this interprocess signaling 
suitably for kamailio?

Best regards,
Vicente.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sip-router.org/pipermail/sr-dev/attachments/20120425/c5af37a7/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: lua02.patch
Type: text/x-diff
Size: 3499 bytes
Desc: not available
URL: <http://lists.sip-router.org/pipermail/sr-dev/attachments/20120425/c5af37a7/attachment.patch>


More information about the sr-dev mailing list