[Catalyst] FastCGI stuff

2006-08-07 Thread Mark Ethan Trostler

Am I on crack or do I really have to make the below changes???:

- My perl 5.8 needs a LENGTH to syswrite.

- ProcManager doesn't like daemonized processes it seems & the code
currently forces the use of one - although the docs for myapp_fastcgi.pl
seems to imply I can just give a -M '' to have no proc manager, but the
code in FastCGI.pm doesn't allow it.
Later in the FastCGI.pm code it checks 'if ($options->{manager}' - which
is always gonna be true unless I comment out that '||=' carnage.

- Finally just 'cuz I a daemon I still want a PID file!!

thanks!
   Mark


--- FastCGI.pm  Mon Aug  7 16:33:15 2006
+++ hack/FastCGI.pm Mon Aug  7 16:33:00 2006
@@ -74,7 +74,7 @@ sub run {
  my $proc_manager;

  if ($listen) {
-$options->{manager} ||= "FCGI::ProcManager";
+# This forces the use of a ProcManager when uncommented
+#  which doesn't seem to like daemonized processes
+#$options->{manager} ||= "FCGI::ProcManager";
  $options->{nproc}   ||= 1;

  $self->daemon_fork() if $options->{detach};
@@ -95,6 +95,11 @@ sub run {
  $proc_manager->pm_manage();
  }
  elsif ( $options->{detach} ) {
+if (my $pid_fname = $options->{pidfile}) {
+open(P, ">$pid_fname");
+print P "$$\n";
+close(P);
+}
  $self->daemon_detach();
  }
  }
@@ -120,7 +125,7 @@ sub write {

  # FastCGI does not stream data properly if using 'print $handle',
  # but a syswrite appears to work properly.
-*STDOUT->syswrite($buffer);
+*STDOUT->syswrite($buffer, length($buffer));
  }

  =head2 $self->daemon_fork()


___
List: Catalyst@lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/


[Catalyst] Streaming (again)

2006-08-31 Thread Mark Ethan Trostler
Ok saw the previous thread on streaming so this should be drop-dead 
simple but it's not working - I'm trying to stream plain text (a la 
'tail -f') to the browser.  I'm using FastCGI in standalone server mode 
- apache 1.x.

Simplified:

sub tail : Local {
 my($self, $c) = @_;

 $c->res->content_type( 'text/html' );

   my $i = 5;
   while($i) {
 $c->res->write("$i");
 $i--;
 sleep(1);
 }
exit;
}

I want to see one line at a time BUT it doesn't show up until after 5 
seconds of 'loading' the page & then it's all there at once.

I've tried c->write(), $c->res->body(), $c->res->output() & whatnot...

What do I need to do to get this to work???

   thanks!!!
Mark

___
List: Catalyst@lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Re: How to redirect before some code excute

2006-10-26 Thread Mark Ethan Trostler

Ajax.
Mark

Christopher H. Laco wrote:

Carl Franks wrote:

On 26/10/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]>
wrote:

Fayland Lam <[EMAIL PROTECTED]> wrote:

Lee Standen wrote:

It's a subroutine, right?

Tried a return?such as:

$c->res->redirect('http://www.yahoo.com');
return undef;

Indeed I want to run the 'while' loop in backend. 'return' would not

run

the loop I think.

Why do you want to run the loop in the background?
What purpose will it serve?

If we can learn your motivation, we can try to find you
At Least One Way To Do It.

It's not that unusual to want to send a response before doing
expensive operations, so that the user doesn't have to wait.

Does fork() play well with catalyst? (I've not yet had a need to try it
myself)

Carl


Personally, rather than fork, I'd suggest some sort of message/request
queue.

-=Chris





___
List: Catalyst@lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/


___
List: Catalyst@lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Re: How to redirect before some code excute

2006-10-26 Thread Mark Ethan Trostler

Perhaps.
I 'system("nohup ... >& /tmp/file &")'
& my page makes ajax calls that gathers /tmp/file & ships it back.
There's some more logic around ensuring the process doesn't get started 
twice & bob's yer uncle.

Mark

For another project I am using activemq & Net::Stomp (& Catalyst) to 
send/receive requests which also works well.  Depends how crazy you 
wanna get.


A. Pagaltzis wrote:

* Mark Ethan Trostler <[EMAIL PROTECTED]> [2006-10-26 19:00]:

Christopher H. Laco wrote:

Personally, rather than fork, I'd suggest some sort of
message/request queue.

Ajax.


Some people, when confronted with a problem, think “I know, I’ll
use Javascript.” Now they have two problems.

(With apologies to Jamie Zawinski.)

Regards,


___
List: Catalyst@lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/