in reply to Can I have a Perl script, initiated from a browser, fork itself, and not wait for the child to end?
My suggestion would be to just run your own http event based sever in perl.
Example this would wait for request to http://localhost/doBigThing, then it sends back text message, then it start doing the big fancy database stuff, before going back to waiting again:
use AnyEvent; use AnyEvent::HTTPD; my $httpd = AnyEvent::HTTPD->new (port => 9090); my $cv = AnyEvent->condvar; $httpd->reg_cb ( '/doBigThing' => sub { my ($httpd, $req) = @_; $req->respond ({ content => ['text/html',"OK starting big datab +ase thingy now... I will be busy for several minutes.... " ]}); $cv->send; } ); while (1) { $cv->recv; print "Doing big fancy database stuff for a long time here..."; $cv = AnyEvent->condvar; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Can I have a Perl script, initiated from a browser, fork itself, and not wait for the child to end?
by bartender1382 (Beadle) on Apr 07, 2022 at 23:05 UTC |
In Section
Seekers of Perl Wisdom