ALL-<div><br></div><div><div>I have a few questions when scripting lua. According to wiki, it is possible to run looping forever lua scripts through start-up config or luarun. </div><div><br></div><div>1) Will the lua script stop when unload mod_lua? I experienced core dump when unload mod_lua while there was a running lua script. Reported on jira.</div>
<div><br></div><div>2) How to stop a forever running lua script?  I stop it by listening a CUSTOM event fired elsewhere. See code below. Is there any standard way like luastop ?</div><div><br></div><div>3) Any way to show how many running lua scripts? luashow ?</div>
<div><br></div><div>4) It seems cannot get the lua script name in a lua script, I made a patch to jira by assign it to the argv[0].</div><div><br></div><div>5) Seems that only EventConsumer(&quot;all&quot;) working. EventConsumer(&quot;CHANNEL_HANUP CUSTOM lua::stop&quot;) doesn&#39;t seem to work. Any idea to this?</div>
<div><br></div><div>Thanks a lot.</div><div><br></div><div><br></div><div>                                               </div><div>code example:</div><div><br></div><div>con = freeswitch.EventConsumer(&quot;all&quot;);      </div>
<div><br></div><div>argv[0] = &quot;test.lua&quot;</div><div>                       </div><div>freeswitch.consoleLog(&quot;info&quot;, &quot;==== Lua Script [&quot; .. argv[0] .. &quot;] Starting =====\n&quot;);</div><div>
                        </div><div>local all_events = 0</div><div>                                                                                                          </div><div>for e in (function() return con:pop(1) end) do</div>
<div>  -- freeswitch.consoleLog(&quot;info&quot;, &quot;event\n&quot; .. e:serialize(&quot;xml&quot;));</div><div>  <span class="Apple-tab-span" style="white-space:pre">        </span>all_events = all_events + 1;</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>freeswitch.consoleLog(&quot;info&quot;, &quot;all_events: &quot; .. all_events .. &quot;\n&quot;)</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>event_name = e:getHeader(&quot;Event-Name&quot;) or &quot;&quot;</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>event_subclass = e:getHeader(&quot;Event-Subclass&quot;) or &quot;&quot;</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>if (event_name == &quot;CUSTOM&quot; and event_subclass == &quot;lua::stop&quot;) then</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>  freeswitch.consoleLog(&quot;info&quot;, &quot;-----lua Script [&quot; .. argv[0] .. &quot;]---Exiting------\n&quot;)</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>  break</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>end</div><div><br></div><div>end </div><div><br></div></div>