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("all") working. EventConsumer("CHANNEL_HANUP CUSTOM lua::stop") doesn'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("all"); </div>
<div><br></div><div>argv[0] = "test.lua"</div><div> </div><div>freeswitch.consoleLog("info", "==== Lua Script [" .. argv[0] .. "] Starting =====\n");</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("info", "event\n" .. e:serialize("xml"));</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("info", "all_events: " .. all_events .. "\n")</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("Event-Name") or ""</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>event_subclass = e:getHeader("Event-Subclass") or ""</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 == "CUSTOM" and event_subclass == "lua::stop") then</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span> freeswitch.consoleLog("info", "-----lua Script [" .. argv[0] .. "]---Exiting------\n")</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>