[Freeswitch-users] A few questions about lua
Seven Du
dujinfang at gmail.com
Thu Aug 6 02:58:59 PDT 2009
ALL-
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.
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.
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 ?
3) Any way to show how many running lua scripts? luashow ?
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].
5) Seems that only EventConsumer("all") working.
EventConsumer("CHANNEL_HANUP CUSTOM lua::stop") doesn't seem to work. Any
idea to this?
Thanks a lot.
code example:
con = freeswitch.EventConsumer("all");
argv[0] = "test.lua"
freeswitch.consoleLog("info", "==== Lua Script [" .. argv[0] .. "] Starting
=====\n");
local all_events = 0
for e in (function() return con:pop(1) end) do
-- freeswitch.consoleLog("info", "event\n" .. e:serialize("xml"));
all_events = all_events + 1;
freeswitch.consoleLog("info", "all_events: " .. all_events .. "\n")
event_name = e:getHeader("Event-Name") or ""
event_subclass = e:getHeader("Event-Subclass") or ""
if (event_name == "CUSTOM" and event_subclass == "lua::stop") then
freeswitch.consoleLog("info", "-----lua Script [" .. argv[0] ..
"]---Exiting------\n")
break
end
end
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20090806/447f6db4/attachment-0002.html
More information about the FreeSWITCH-users
mailing list