<div dir="auto">Will repeat reply here as sent it only to Daniel first<div dir="auto"><br></div><div dir="auto"><span style="font-family:sans-serif;font-size:12.8px">Yep. You understand right. </span><div dir="auto" style="font-family:sans-serif;font-size:12.8px"><br></div><div dir="auto" style="font-family:sans-serif;font-size:12.8px">Here need to add some context then :-) </div><div dir="auto" style="font-family:sans-serif;font-size:12.8px"><br></div><div dir="auto" style="font-family:sans-serif;font-size:12.8px">All my scripts "main.lua" ( that passed via <b>modparam</b> <b>load) </b>with cfg engine lua starts as</div><div dir="auto" style="font-family:sans-serif;font-size:12.8px"><br></div><div dir="auto" style="font-family:sans-serif;font-size:12.8px"><i>function initPath() </i></div><div dir="auto" style="font-family:sans-serif;font-size:12.8px"><div dir="auto"><i>local myPath = debug.getinfo(1).source:match("@?(.*/)")</i></div><div dir="auto"><i>if not string.match(package.path, myPath) then</i></div><div dir="auto"><i>    package.path = myPath .. '?.lua;' .. package.path</i></div><div dir="auto"><i>end</i></div><div dir="auto"><i><b>KSR.log</b>("debug","package path loaded: ".. </i><i>package.path) </i></div><div dir="auto"><i>end</i></div><div dir="auto"><i><br></i></div><div dir="auto"><font face="sans-serif">That I run as first step inside of all global functions like <i style="font-weight:bold">ksr_request_route() </i>and etc</font></div><div dir="auto"><font face="sans-serif"><br></font></div><div dir="auto"><div dir="auto">This gives me possibility to load modules which lays at the subdirs near my "<b>main.lua</b>" file that is kinda entry point</div><div dir="auto"><br></div><div dir="auto">I can run it as global function too before others global function ofcourse, but without <b>KSR.log()</b></div><br></div><div dir="auto"><font face="sans-serif">For .<b>cfg </b>files Where I use lua_run()  as extension I have the same structure of lua modules and files and also run this function on the main.lua for the same purpose </font><b>But  </b>at the main<b> </b>flow, not inside function that Im calling via <i>lua_run() </i></div><div dir="auto"><br></div><div dir="auto">So accidently I started to run it at the main flow  but forgot to remove <b>KSR.log()</b> and, actually, I expected to see </div><div dir="auto">Lua error like "KSR not defined" or etc. But this gave me different error that at the start of the topic and that confused me :-) </div></div></div><div dir="auto"><br></div><div dir="auto">If need more clrification: I will be able to do it later on. Just let me know. </div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, 18 Sep 2019, 08:44 Daniel-Constantin Mierla, <<a href="mailto:miconda@gmail.com">miconda@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  
    
  
  <div text="#000000" bgcolor="#FFFFFF">
    <p><br>
    </p>
    <div class="m_-8054072292624202250moz-cite-prefix">On 16.09.19 21:08, Yuriy Gorlichenko
      wrote:<br>
    </div>
    <blockquote type="cite">
      
      <div dir="ltr">I found issue: <br>
        Called  KSR.log earlier than it was initiated. <br>
        Moved part of code previously used in cfgengine "lua" to
        lua_run().</div>
    </blockquote>
    <p><br>
    </p>
    <p>Just to clarify: the issue was exposed because you moved some
      code that was used previously with cfgengine lua to a lua_run()
      usage? The KSR should be initialized quite early, that's why I am
      trying to figure out if there are cases when Lua code can be
      executed (due to some modparams or event routes) and the
      environment is not set, in order to find some solution for such
      cases. So if you can provide more details about how was used and
      not working, it may get fixes if it is a viable use case.</p>
    <p>Cheers,<br>
      Daniel<br>
    </p>
    <p><br>
    </p>
    <blockquote type="cite"><br>
      <div class="gmail_quote">
        <div dir="ltr" class="gmail_attr">пн, 16 сент. 2019 г. в 15:25,
          Yuriy Gorlichenko <<a href="mailto:ovoshlook@gmail.com" target="_blank" rel="noreferrer">ovoshlook@gmail.com</a>>:<br>
        </div>
        <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
          <div dir="auto">Sorry Just a mistake. Offcourse it is path to
            kamailio.cfg file which contains path to main.lua as
            modparam. Sorry for confusing</div>
          <br>
          <div class="gmail_quote">
            <div dir="ltr" class="gmail_attr">On Mon, 16 Sep 2019, 10:45
              Daniel-Constantin Mierla, <<a href="mailto:miconda@gmail.com" target="_blank" rel="noreferrer">miconda@gmail.com</a>> wrote:<br>
            </div>
            <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
              <div dir="ltr">
                <div>Hello,</div>
                <div><br>
                </div>
                <div>is it "kamailio -f /etc/kamailio/extended/main.lua"
                  or just a typing mistake, because the config path
                  provided with -f should still be to the kamailio.cfg
                  where you set global parameters, load modules and set
                  their parameters?</div>
                <div><br>
                </div>
                <div>Cheers,</div>
                <div>Daniel<br>
                </div>
              </div>
              <br>
              <div class="gmail_quote">
                <div dir="ltr" class="gmail_attr">On Mon, Sep 16, 2019
                  at 7:23 AM Yuriy Gorlichenko <<a href="mailto:ovoshlook@gmail.com" rel="noreferrer noreferrer" target="_blank">ovoshlook@gmail.com</a>>
                  wrote:<br>
                </div>
                <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
                  <div dir="ltr">Hi! Im using kamailio 5.1.8 with
                    app_lua and getting this message during startup of
                    kamailio. Looks like I forgot to add something at
                    the module setup, but cant figure out what is wrong.
                    My setup of app_lua is:<br>
                    <br>
                    modparam("app_lua", "load",
                    "/etc/kamailio/extended/main.lua")<br>
                    modparam("app_lua","reload",1)<br>
                    modparam("app_lua","register","textops")<br>
                    <br>
                    app_lua [app_lua_sr.c:1599]:
                    sr_kemi_lua_exec_func_ex(): invalid Lua environment
                    attributes or parameters<br>
                    <br>
                    starting kamailio service with kamailio -f
                    /etc/kamailio/extended/main.lua<br>
                    <br>
                    Also here is little bit confusing me that in case of
                    use "KSR" everywhere I'm getting message about
                    "sr"...<br>
                    <br>
                    Thx in advice</div>
                  _______________________________________________<br>
                  Kamailio (SER) - Users Mailing List<br>
                  <a href="mailto:sr-users@lists.kamailio.org" rel="noreferrer noreferrer" target="_blank">sr-users@lists.kamailio.org</a><br>
                  <a href="https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users" rel="noreferrer noreferrer noreferrer" target="_blank">https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users</a><br>
                </blockquote>
              </div>
              <br clear="all">
              <br>
              -- <br>
              <div dir="ltr" class="m_-8054072292624202250gmail-m_-8232644339647112643m_43655598967148316gmail_signature">
                <div dir="ltr">
                  <div>
                    <div dir="ltr">
                      <div>Daniel-Constantin Mierla - <a href="http://www.asipto.com" rel="noreferrer noreferrer" target="_blank">http://www.asipto.com</a></div>
                      <div><a href="http://twitter.com/#!/miconda" rel="noreferrer noreferrer" target="_blank">http://twitter.com/#!/miconda</a>
                        - <a href="http://www.linkedin.com/in/miconda" rel="noreferrer noreferrer" target="_blank">http://www.linkedin.com/in/miconda</a></div>
                    </div>
                  </div>
                </div>
              </div>
              _______________________________________________<br>
              Kamailio (SER) - Users Mailing List<br>
              <a href="mailto:sr-users@lists.kamailio.org" rel="noreferrer noreferrer" target="_blank">sr-users@lists.kamailio.org</a><br>
              <a href="https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users" rel="noreferrer noreferrer noreferrer" target="_blank">https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users</a><br>
            </blockquote>
          </div>
        </blockquote>
      </div>
      <br>
      <fieldset class="m_-8054072292624202250mimeAttachmentHeader"></fieldset>
      <pre class="m_-8054072292624202250moz-quote-pre">_______________________________________________
Kamailio (SER) - Users Mailing List
<a class="m_-8054072292624202250moz-txt-link-abbreviated" href="mailto:sr-users@lists.kamailio.org" target="_blank" rel="noreferrer">sr-users@lists.kamailio.org</a>
<a class="m_-8054072292624202250moz-txt-link-freetext" href="https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users" target="_blank" rel="noreferrer">https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users</a>
</pre>
    </blockquote>
    <pre class="m_-8054072292624202250moz-signature" cols="72">-- 
Daniel-Constantin Mierla -- <a class="m_-8054072292624202250moz-txt-link-abbreviated" href="http://www.asipto.com" target="_blank" rel="noreferrer">www.asipto.com</a>
<a class="m_-8054072292624202250moz-txt-link-abbreviated" href="http://www.twitter.com/miconda" target="_blank" rel="noreferrer">www.twitter.com/miconda</a> -- <a class="m_-8054072292624202250moz-txt-link-abbreviated" href="http://www.linkedin.com/in/miconda" target="_blank" rel="noreferrer">www.linkedin.com/in/miconda</a>
Kamailio Advanced Training, Oct 21-23, 2019, Berlin, Germany -- <a class="m_-8054072292624202250moz-txt-link-freetext" href="https://asipto.com/u/kat" target="_blank" rel="noreferrer">https://asipto.com/u/kat</a></pre>
  </div>

</blockquote></div>