On Tue, Jan 4, 2011 at 6:01 PM, Tiago Katcipis <katci...@inf.ufsc.br> wrote:

>
>
> On Tue, Jan 4, 2011 at 5:41 PM, Fabio Mascarenhas <mascaren...@acm.org>wrote:
>
>> If you want to run just a single, persistent WSAPI application it is much
>> easier to use this as your idlocutor.fcgi script:
>>
>> ----
>> pcall(require,"luarocks.require")
>>
>> local fastcgi = require "wsapi.fastcgi"
>> local myapp = require "myapp"
>>
>> fastcgi.run(myapp.run)
>> ----
>>
>> Where myapp.run is your WSAPI entry point (that takes a WSAPI
>> environment).
>>
>
> That's a nice idea, thanks Fábio.
>
>
>>
>> BTW, what version of WSAPI are you using? The common loader had a bug.
>>
>
So, the bug was in the version 1.3.4 or i was doing something terribly
wrong?

I'm not using the loader anymore.. but I'm a little curious on the cause of
the problem :-).

Best regards,
Katcipis


>
> I'm using the version 1.3.4.
>
> I'm going to try your idea and see if any other problem arises.
>
> Best regards,
> Katcipis
>
>
>>
>> --
>> Fabio Mascarenhas
>>
>>
>> On Tue, Jan 4, 2011 at 4:32 PM, Tiago Katcipis <katci...@inf.ufsc.br>wrote:
>>
>>> On Mon, Jan 3, 2011 at 11:27 AM, Tiago Katcipis <katci...@inf.ufsc.br>wrote:
>>>
>>>>
>>>>
>>>> On Mon, Jan 3, 2011 at 11:15 AM, Fabio Mascarenhas <mascaren...@acm.org
>>>> > wrote:
>>>>
>>>>> With isolated=true WSAPI will run your scripts in a pool of Rings, and
>>>>> will collect and respawn the Rings periodically,
>>>>>
>>>>
>>>> besides periodically, on any 4XX and on DELETE method it will be
>>>> respawned too? just for curiosity :-).
>>>>
>>>>
>>>>> so isolated=false is the behavior you want, as you are only running a
>>>>> single script anyway.
>>>>>
>>>>
>>>> everything is working ok now, it took some time and a good read on the
>>>> source to understand this clearly.
>>>>
>>>
>>> With a little further testing...things seems to not be that ok after all.
>>>
>>> After making a lot of requests (GET, POST, DELETE) wsapi starts to
>>> respond the following:
>>>
>>> *<html>
>>>         <head><title>WSAPI Error in Application</title></head>
>>>         <body>
>>>         <p>There was an error in the specified application.
>>>         The full error message follows:</p>
>>> <pre>
>>> /usr/lib/lua/5.1/wsapi/common.lua:78: not a valid WSAPI application
>>> stack traceback:
>>>     [C]: in function 'error'
>>>     /usr/lib/lua/5.1/wsapi/common.lua:78: in function
>>> </usr/lib/lua/5.1/wsapi/common.lua:65>
>>>     (tail call): ?
>>>     (tail call): ?
>>>     /usr/lib/lua/5.1/wsapi/common.lua:710: in function
>>> 'load_wsapi_persistent'
>>>     /usr/lib/lua/5.1/wsapi/common.lua:728: in function
>>> </usr/lib/lua/5.1/wsapi/common.lua:721>
>>>     (tail call): ?
>>>     (tail call): ?
>>>     [C]: in function 'xpcall'
>>>     /usr/lib/lua/5.1/wsapi/common.lua:254: in function 'run_app'
>>>     /usr/lib/lua/5.1/wsapi/common.lua:281: in function 'run'
>>>     /usr/lib/lua/5.1/wsapi/fastcgi.lua:40: in function 'run'
>>>     ./idlocutor.fcgi:20: in main chunk
>>>     [C]: ?
>>> </pre>
>>>         </body>
>>>         </html>
>>>
>>> *It happens randomly (taking a look at the debug of my fastcgi, no error
>>> is reported, everything is working fine, suddenly this error starts and my
>>> fastcgi is not even called), and what could mean "not a valid WSAPI
>>> application" ??? My lua script stopped to be a WSAPI application ?
>>>
>>> It does not try to reload the script, the only way i can get out of it is
>>> by killing the fastcgi process (wsapi.fastcgi). So the server starts a new
>>> one and everything goes back to normal...until the problem happens again.
>>> *
>>>
>>> *someone has a hint of what this could be? it started to happens with
>>> the isolated = false option.*
>>>
>>> *Best regards,
>>> Katcipis*
>>>
>>> *
>>>
>>>>
>>>> Thanks for the help,
>>>> Katcipis
>>>>
>>>>
>>>>>
>>>>> --
>>>>> Fabio Mascarenhas
>>>>>
>>>>> On Wed, Dec 29, 2010 at 2:48 PM, Tiago Katcipis 
>>>>> <katci...@inf.ufsc.br>wrote:
>>>>>
>>>>>>
>>>>>>
>>>>>> On Wed, Dec 29, 2010 at 11:31 AM, Tiago Katcipis <
>>>>>> katci...@inf.ufsc.br> wrote:
>>>>>>
>>>>>>> Hi all,
>>>>>>>
>>>>>>> I'm having some problem using wsapi-fastcgi with lighthttpd. I got
>>>>>>> everything working fine, but every time an error occurs (any 4xx) or 
>>>>>>> someone
>>>>>>> send a DELETE method request my script is reloaded. I don't want the 
>>>>>>> script
>>>>>>> to reload because every time this happens i reconnect to the db and the
>>>>>>> older connections get lost and the db continues to consume resources (on
>>>>>>> this case is mongo db, a thread gets locked forever each time my script 
>>>>>>> is
>>>>>>> reloaded).
>>>>>>>
>>>>>>> When there is no error 4XX or DELETE everything works as expected,
>>>>>>> the script is not reloaded on each request and the connection is reused 
>>>>>>> (i
>>>>>>> run an init function when the script is loaded, but it is supposed to 
>>>>>>> run
>>>>>>> only once and them handle the requests without reloading).
>>>>>>>
>>>>>>> Here is the configuration that i run the fastcgi:
>>>>>>>
>>>>>>> #!/usr/bin/lua
>>>>>>> local common = require "wsapi.common"
>>>>>>> local fastcgi = require "wsapi.fastcgi"
>>>>>>>
>>>>>>> local ONE_HOUR = 60 * 60
>>>>>>> local ONE_DAY = 24 * ONE_HOUR
>>>>>>>
>>>>>>> local wsapi_loader = common.make_loader{
>>>>>>>   isolated = true,             -- isolate each script in its own Lua
>>>>>>> state
>>>>>>>
>>>>>>
>>>>>> Taking a good look at the code i just changed the isolated = true to
>>>>>> false, so it would call the make_persistent_loader instead of the 
>>>>>> isolated.
>>>>>> It worked fine just as i expected, still don't know why with isolated = 
>>>>>> true
>>>>>> it reloads the script when returning a 4XX or receiving a DELETE.
>>>>>>
>>>>>> I'm working with only one script, so the problem seems resolved to me.
>>>>>>
>>>>>> Sorry for the noise.
>>>>>>
>>>>>> Best regards,
>>>>>> Katcipis
>>>>>>
>>>>>>
>>>>>>>   filename = nil,  -- if you want to force the launch of a single
>>>>>>> script
>>>>>>>   launcher = "idlocutor.fcgi", -- the name of this script
>>>>>>>   reload = false,              -- if you want to reload the
>>>>>>> application on every request
>>>>>>>   period = ONE_HOUR,           -- frequency of Lua state staleness
>>>>>>> checks
>>>>>>>   ttl = ONE_DAY,               -- time-to-live for Lua states
>>>>>>>   vars =                       -- order of checking for the path of
>>>>>>> the script
>>>>>>>    { "SCRIPT_FILENAME",
>>>>>>>      "PATH_TRANSLATED" }
>>>>>>> }
>>>>>>>
>>>>>>> fastcgi.run(wsapi_loader)
>>>>>>>
>>>>>>>
>>>>>>> i tried to take a look on wsapi.fastcgi and them on wsapi.commom to
>>>>>>> understand why it could be reloading my script, i understood that when 
>>>>>>> the
>>>>>>> file is modified or reload is true it will reload the script on a new
>>>>>>> lua_State, but i was unable to find another moment when this is
>>>>>>> done..related to the errors (the rings logic is not too much easy to
>>>>>>> understand, specially to me, never used rings).
>>>>>>>
>>>>>>> this reload problem (or maybe expected behaviour....i don't know) is
>>>>>>> caused by wsapi? wsapi-fastcgi? or is something related to lighthttpd? 
>>>>>>> (i
>>>>>>> doubt of that because the pid of the fastcgi process remains the 
>>>>>>> same...it
>>>>>>> seems that wsapi is reloading the script internally)  I'm kinda new to 
>>>>>>> web
>>>>>>> development, sorry I'm asking something stupid.
>>>>>>>
>>>>>>>
>>>>>>> best regards,
>>>>>>> Katcipis
>>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> http://www.getgnulinux.org/windows
>>>>>>
>>>>>> _______________________________________________
>>>>>> Kepler-Project mailing list
>>>>>> Kepler-Project@lists.luaforge.net
>>>>>> http://lists.luaforge.net/cgi-bin/mailman/listinfo/kepler-project
>>>>>> http://www.keplerproject.org/
>>>>>>
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> Kepler-Project mailing list
>>>>> Kepler-Project@lists.luaforge.net
>>>>> http://lists.luaforge.net/cgi-bin/mailman/listinfo/kepler-project
>>>>> http://www.keplerproject.org/
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> http://www.getgnulinux.org/windows
>>>>
>>>
>>>
>>>
>>> --
>>> http://www.getgnulinux.org/windows
>>>
>>> _______________________________________________
>>> Kepler-Project mailing list
>>> Kepler-Project@lists.luaforge.net
>>> http://lists.luaforge.net/cgi-bin/mailman/listinfo/kepler-project
>>> http://www.keplerproject.org/
>>>
>>
>>
>> _______________________________________________
>> Kepler-Project mailing list
>> Kepler-Project@lists.luaforge.net
>> http://lists.luaforge.net/cgi-bin/mailman/listinfo/kepler-project
>> http://www.keplerproject.org/
>>
>
>
>
> --
> http://www.getgnulinux.org/windows
>



-- 
http://www.getgnulinux.org/windows
_______________________________________________
Kepler-Project mailing list
Kepler-Project@lists.luaforge.net
http://lists.luaforge.net/cgi-bin/mailman/listinfo/kepler-project
http://www.keplerproject.org/

Reply via email to