Re: [SR-Users] app_lua reload - what exactly gets reloaded?

2017-07-10 Thread Daniel-Constantin Mierla
Hello,


On 07.07.17 15:02, Sebastian Damm wrote:
> Hi,
>
> On Thu, Jul 6, 2017 at 12:26 PM, Daniel-Constantin Mierla
>  wrote:
>> You can check a shared memory variable (like $sht(...) or $shv(...))
>> that you can change via rpc, so you can re-fetch the database records
>> even if you don't change the lua script.
> I've implemented it as suggested, and it works as expected.
>
> Thanks as always for the valuable input.
>
ok, great!

Maybe someone is going to implement the interpreter reset feature, could
be useful as well, although so far I didn't need it at all.

Cheers,
Daniel

-- 
Daniel-Constantin Mierla
www.twitter.com/miconda -- www.linkedin.com/in/miconda
Kamailio Advanced Training - www.asipto.com
Kamailio World Conference - www.kamailioworld.com


___
Kamailio (SER) - Users Mailing List
sr-users@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users


Re: [SR-Users] app_lua reload - what exactly gets reloaded?

2017-07-07 Thread Sebastian Damm
Hi,

On Thu, Jul 6, 2017 at 12:26 PM, Daniel-Constantin Mierla
 wrote:
> You can check a shared memory variable (like $sht(...) or $shv(...))
> that you can change via rpc, so you can re-fetch the database records
> even if you don't change the lua script.

I've implemented it as suggested, and it works as expected.

Thanks as always for the valuable input.

Best Regards,
Sebastian

___
Kamailio (SER) - Users Mailing List
sr-users@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users


Re: [SR-Users] app_lua reload - what exactly gets reloaded?

2017-07-06 Thread Daniel-Constantin Mierla
Hello,


On 06.07.17 10:51, Sebastian Damm wrote:
> Hi,
>
> On Thu, Jul 6, 2017 at 10:16 AM, Daniel-Constantin Mierla
>  wrote:
>> it sounds like you want to re-initialize the Lua interpreter, not to
>> reload the Lua script. If you want a fully fresh Lua interpreter, then
>> at this moment you have to restart kamailio.
> Does the script get some kind of notification that a reload took place?
>
> Is there any variable or something that I can use inside the script to
> check whether it was just reloaded? It's really just an
> initialisation. My script has to fetch some database entries once to
> work. So if I could react on a signal or other kind of notification,
> this could help, too.
>
You can check a shared memory variable (like $sht(...) or $shv(...))
that you can change via rpc, so you can re-fetch the database records
even if you don't change the lua script.

Having an indication on script reload inside the script itself could be
useful, but requires some c coding at this moment, not being implemented.

Cheers,
Daniel

-- 
Daniel-Constantin Mierla
www.twitter.com/miconda -- www.linkedin.com/in/miconda
Kamailio Advanced Training - www.asipto.com
Kamailio World Conference - www.kamailioworld.com


___
Kamailio (SER) - Users Mailing List
sr-users@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users


Re: [SR-Users] app_lua reload - what exactly gets reloaded?

2017-07-06 Thread Daniel-Constantin Mierla
Hello,


On 06.07.17 10:02, Sebastian Damm wrote:
> Hi,
>
> On Wed, Jul 5, 2017 at 6:47 PM, Daniel-Constantin Mierla
>  wrote:
>> the reload command marks the scripts specified by 'load' parameter to be
>> reloaded next time they are going to be used.
> That's what I saw in the debug logs. But what does that exactly mean?
> I thought the script would get reinitialized and starts with a fresh
> state. As if I would restart Kamailio only without all the Kamailio
> initialization. But that seems not to be true. My "initialize" method
> is not called, because the global object variable is already set
> (which isn't when the script is executed after Kamailio was started).
>
> Is there any way to "reset" the script except restarting Kamailio?
>
it sounds like you want to re-initialize the Lua interpreter, not to
reload the Lua script. If you want a fully fresh Lua interpreter, then
at this moment you have to restart kamailio.

Cheers,
Daniel

-- 
Daniel-Constantin Mierla
www.twitter.com/miconda -- www.linkedin.com/in/miconda
Kamailio Advanced Training - www.asipto.com
Kamailio World Conference - www.kamailioworld.com


___
Kamailio (SER) - Users Mailing List
sr-users@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users


Re: [SR-Users] app_lua reload - what exactly gets reloaded?

2017-07-06 Thread Sebastian Damm
Hi,

On Wed, Jul 5, 2017 at 6:47 PM, Daniel-Constantin Mierla
 wrote:
> the reload command marks the scripts specified by 'load' parameter to be
> reloaded next time they are going to be used.

That's what I saw in the debug logs. But what does that exactly mean?
I thought the script would get reinitialized and starts with a fresh
state. As if I would restart Kamailio only without all the Kamailio
initialization. But that seems not to be true. My "initialize" method
is not called, because the global object variable is already set
(which isn't when the script is executed after Kamailio was started).

Is there any way to "reset" the script except restarting Kamailio?

Regards,
Sebastian

___
Kamailio (SER) - Users Mailing List
sr-users@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users


Re: [SR-Users] app_lua reload - what exactly gets reloaded?

2017-07-05 Thread Daniel-Constantin Mierla
Hello,


On 05.07.17 15:00, Sebastian Damm wrote:
> Hi,
>
> we have written some logic for a project in lua. There is a small
> function that gets called from Kamailio, but the main logic is done in
> a self-written module. That module does initialize some values from
> database on the first request that comes in.
>
> Now when reloading app_lua from kamcmd or via jsonrpc, I don't see the
> log output generated when initializing.
>
> In the debug log, I can see that the reload is taking place, but the
> variables and state seem to not get reset.
>
> What does the reload command actually reload?
>
>
the reload command marks the scripts specified by 'load' parameter to be
reloaded next time they are going to be used.

Cheers,
Daniel

-- 
Daniel-Constantin Mierla
www.twitter.com/miconda -- www.linkedin.com/in/miconda
Kamailio Advanced Training - www.asipto.com
Kamailio World Conference - www.kamailioworld.com


___
Kamailio (SER) - Users Mailing List
sr-users@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users


[SR-Users] app_lua reload - what exactly gets reloaded?

2017-07-05 Thread Sebastian Damm
Hi,

we have written some logic for a project in lua. There is a small
function that gets called from Kamailio, but the main logic is done in
a self-written module. That module does initialize some values from
database on the first request that comes in.

Now when reloading app_lua from kamcmd or via jsonrpc, I don't see the
log output generated when initializing.

In the debug log, I can see that the reload is taking place, but the
variables and state seem to not get reset.

What does the reload command actually reload?

Best Regards,
Sebastian

___
Kamailio (SER) - Users Mailing List
sr-users@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users