[Freeswitch-users] stop a running lua script from luarun

Areski areski at gmail.com
Sat Dec 29 23:48:20 MSK 2012


I use to send a custom even to stop a lua script which run an infinite loop
:
luarun myscript.lua stop

if argv[1] then
    i=1
    while argv[i] do
        if argv[i] == "stop" then
            --Send Stop message
            local event = freeswitch.Event("custom", "lua::stop_event")
            event:addHeader("Action", "stop")
            event:fire()
            logger("Sent stop message to lua script")
            return
        end
        i=i+1
    end
    return
end

and then in the loop I listen for those events!

you can find a full example here :
https://github.com/Star2Billing/newfies-dialer/blob/develop/lua/listener.lua



On Wed, Dec 26, 2012 at 8:12 PM, Muhammad Naseer Bhatti
<nbhatti at gmail.com>wrote:

>
> No, I am running this loop myself. But I found other way to terminate the
> script, like look for a condition  in each iteration of the loop and if
> condition is true terminate the loop. But the question remains the same, if
> there is a way to figure out which scripts are running  to stop them if
> possible. Since all process are spawn by freeswitch top -H is not a handy
> solution.
>
>
> Thanks,
> --
> Muhammad Naseer Bhatti
>
>
>
> On Dec 26, 2012, at 8:14 PM, Michael Collins <msc at freeswitch.org> wrote:
>
> Have you been able to determine why it's stuck in an infinite loop? That
> would be a better long-term solution. In the meantime I think you can do
> top -H to see individual threads but I don't know how easy/difficult it is
> to pick out which one is running Lua.
> -MC
>
> On Sun, Dec 23, 2012 at 2:21 AM, Muhammad Naseer Bhatti <nbhatti at gmail.com
> > wrote:
>
>>
>> Looks like simple one, but I can't figure it out if there a way to stop a
>> lua script invoked via luarun which is stuck in an infinite loop and won't
>> terminate itself? Of if we can come up with a way to monitor the thread and
>> stop it?
>>
>> Thanks,
>> --
>> Muhammad Naseer Bhatti
>>
>>
>>
>>
>> _________________________________________________________________________
>> Professional FreeSWITCH Consulting Services:
>> consulting at freeswitch.org
>> http://www.freeswitchsolutions.com
>>
>> 
>> 
>>
>> Official FreeSWITCH Sites
>> http://www.freeswitch.org
>> http://wiki.freeswitch.org
>> http://www.cluecon.com
>>
>> FreeSWITCH-users mailing list
>> FreeSWITCH-users at lists.freeswitch.org
>> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
>> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
>> http://www.freeswitch.org
>>
>>
>
>
> --
> Michael S Collins
> Twitter: @mercutioviz
> http://www.FreeSWITCH.org <http://www.freeswitch.org/>
> http://www.ClueCon.com <http://www.cluecon.com/>
> http://www.OSTAG.org <http://www.ostag.org/>
>
> _________________________________________________________________________
> Professional FreeSWITCH Consulting Services:
> consulting at freeswitch.org
> http://www.freeswitchsolutions.com
>
> 
> 
>
> Official FreeSWITCH Sites
> http://www.freeswitch.org
> http://wiki.freeswitch.org
> http://www.cluecon.com
>
> FreeSWITCH-users mailing list
> FreeSWITCH-users at lists.freeswitch.org
> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
> http://www.freeswitch.org
>
>
>
> _________________________________________________________________________
> Professional FreeSWITCH Consulting Services:
> consulting at freeswitch.org
> http://www.freeswitchsolutions.com
>
> 
> 
>
> Official FreeSWITCH Sites
> http://www.freeswitch.org
> http://wiki.freeswitch.org
> http://www.cluecon.com
>
> FreeSWITCH-users mailing list
> FreeSWITCH-users at lists.freeswitch.org
> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
> http://www.freeswitch.org
>
>


-- 
Kinds regards,
/Areski

----
*Arezqui Belaid*,
areski at gmail.com / +34650784355

Founder at Star2Billing (www.star2billing.com)
Author @ A2Billing (www.a2billing.net), @ Newfies-Dialer (
www.newfies-dialer.org), @ CDR-Stats (www.cdr-stats.org)
----
Twitter : http://twitter.com/areskib / LinkedIN :
http://www.linkedin.com/in/areski
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20121229/c14d21ee/attachment-0001.html 


Join us at ClueCon 2011 Aug 9-11, 2011
More information about the FreeSWITCH-users mailing list