[prev in list] [next in list] [prev in thread] [next in thread] 

List:       sr-users
Subject:    Re: [SR-Users] Possibility of kemi lua to keep lua global vars
From:       Daniel-Constantin Mierla <miconda () gmail ! com>
Date:       2018-04-26 6:47:57
Message-ID: 88556adf-7a2c-d995-38ad-6de5fffa4ea2 () gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


Hello,

have you look at the PID, is it done for the same process? Can you send
some sample syslog messages?

Also what is the version of your lua?

Cheers,
Daniel


On 25.04.18 07:15, Yuriy Gorlichenko wrote:
> 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?
>
>
>
>
> _______________________________________________
> Kamailio (SER) - Users Mailing List
> sr-users@lists.kamailio.org
> https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users

-- 
Daniel-Constantin Mierla
www.twitter.com/miconda -- www.linkedin.com/in/miconda
Kamailio World Conference - May 14-16, 2018 - www.kamailioworld.com


[Attachment #5 (text/html)]

<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <p>Hello,</p>
    <p>have you look at the PID, is it done for the same process? Can
      you send some sample syslog messages?</p>
    <p>Also what is the version of your lua?<br>
    </p>
    <p>Cheers,<br>
      Daniel<br>
    </p>
    <br>
    <div class="moz-cite-prefix">On 25.04.18 07:15, Yuriy Gorlichenko
      wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CABSP_VdBg40gH9LCjQx-SDrb+JEddLNGQsaSHJaXF3Xe38-Gmw@mail.gmail.com">
      <div dir="ltr">Hi<br>
        For now as I see:  every request that calls lua script reevables
        my global lua variables <br>
        <br>
        For example
        <div><br>
          I trying to connect to DB via luasql driver and checking if
          connection already existis to avoid new connection<br>
          <br>
          I have function init() that calls in ksr_request_route()<br>
          <br>
          Inside i have ome check: <br>
          <br>
          if not CON then <br>
          <div><br>
          </div>
          <div>    CON =
assert(MYSQL:connect(DBdata.dbname,DBdata.username,DBdata.password,DBdata.host,DBdata.port))</div>
  <div><br>
          </div>
          <div><span style="white-space:pre">		</span>if not CON then</div>
          <div><span style="white-space:pre">			</span>KSR.log("info","|init|log|
            DB NOT connected\n")</div>
          <div><span \
style="white-space:pre">			</span>KSR.sl.sl_send_reply(503,"Internal  server error") \
</div>  <div><span style="white-space:pre">			</span>KSR.x.exit()</div>
          <div><span style="white-space:pre">		</span>else </div>
          <div><span style="white-space:pre">			</span>KSR.log("info","|init|log|
            DB connected\n")</div>
          <div><span style="white-space:pre">		</span>end</div>
          <div>end<br>
            <br>
            So in this case if CON was already created it should not try
            to connect<br>
            <br>
            But for now it tries for every request. So means kemi not
            stores global lua variables between sessions (in one
            kamailio process)<br>
            <br>
            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<br>
            <br>
            So my question is there is a way to keep global vars per
            kamailio process instead per kamailio request?<br>
            <br>
            <br>
          </div>
        </div>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
Kamailio (SER) - Users Mailing List
<a class="moz-txt-link-abbreviated" \
href="mailto:sr-users@lists.kamailio.org">sr-users@lists.kamailio.org</a> <a \
class="moz-txt-link-freetext" \
href="https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users">https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users</a>
 </pre>
    </blockquote>
    <br>
    <pre class="moz-signature" cols="72">-- 
Daniel-Constantin Mierla
<a class="moz-txt-link-abbreviated" \
href="http://www.twitter.com/miconda">www.twitter.com/miconda</a> -- <a \
class="moz-txt-link-abbreviated" \
href="http://www.linkedin.com/in/miconda">www.linkedin.com/in/miconda</a> Kamailio \
World Conference - May 14-16, 2018 - <a class="moz-txt-link-abbreviated" \
href="http://www.kamailioworld.com">www.kamailioworld.com</a></pre>  </body>
</html>


[Attachment #6 (text/plain)]

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


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic