Re: [cgiapp] Keep connection alive for request that takes long time to run

2010-02-10 Thread Michael Peters
On 02/10/2010 10:38 AM, Shao, David (NIH/NLM/NCBI) [C] wrote:

 I use CGI::Application for my web app. The app sometimes takes longer to run 
 than the timeout limit set by the apache server, which results in a 'Bad 
 Gateway' page at user side. My web admin suggested I need to implement 
 something similar to 'heartbeat' to keep the connection alive. My 
 interpretation to this is, while my app is running, it needs to send a 
 'keepalive' packet to the client in short intervals (i.e. shorter than the 
 timeout limit), to prevent the server from dropping the connection. I am 
 fairly new to CGI::Application, and my questions are if this feature already 
 exists (but I can't find it in documentation), or if it is not, is it 
 possible to implement using CGI::Application?

The is similar to what the C::A::Plugin::Stream does. Basically you tell 
C::A not to send headers and then you print your own response. The 
difference being that you don't want to send actual content while your 
app is working, but just empty data to hold the connection. Something 
like this:

   $self-header_type('none');
   my $not_done = 0;
   while($not_done) {
 print \0; # send null byte to keep the connection open
 ... # do some work
   }

If the long running task you want to do can't be broken up into chunks 
such that you can print a null byte, then you need to rethink your 
architecture. Probably best to think about having a job queue which does 
the work and a URL that your page contantly hits to figure out if the 
job is done. When it's done you can then redirect the client to where 
you want them to go.

-- 
Michael Peters
Plus Three, LP

#  CGI::Application community mailing list  
####
##  To unsubscribe, or change your message delivery options,  ##
##  visit:  http://www.erlbaum.net/mailman/listinfo/cgiapp##
####
##  Web archive:   http://www.erlbaum.net/pipermail/cgiapp/   ##
##  Wiki:  http://cgiapp.erlbaum.net/ ##
####




[cgiapp] YAPC

2010-02-10 Thread Leonard Miller
Hey all,

It is time for me to stop lurking for a bit and come out of the shadows.

My reason for stepping forward, is to ask all of you who intends to 
submit CGI::Application talks to YAPC this summer? The call for talks is 
open for YAPC::NA, and last year none of our talks were submitted, so I 
figured that if we were to be a little better represented then we could 
get some talks accepted.

If we don't sell our product, then it will die. We don't want that.

It remains to be seen if I will be able to make it to YAPC::NA, so I 
will probably not be able to speak on our framework. Lets see if we can 
get a few people who really want to speak, and pair them up with others 
here who have the knowledge, but don't want to speak.

If you are going to YAPC::EU or YAPC::NA then speak up here.

Thank you for listening

Leonard

#  CGI::Application community mailing list  
####
##  To unsubscribe, or change your message delivery options,  ##
##  visit:  http://www.erlbaum.net/mailman/listinfo/cgiapp##
####
##  Web archive:   http://www.erlbaum.net/pipermail/cgiapp/   ##
##  Wiki:  http://cgiapp.erlbaum.net/ ##
####