On 23/09/2014 11:25, Gabor Szabo wrote: > > > On Mon, Sep 22, 2014 at 12:17 PM, Chanan Berler <[email protected] > <mailto:[email protected]>> wrote: > > Hello All, > > I need to create a module that opens a persistent SSH connection > between X servers > and send same system commands to all of them. > > I have used Net::OpenSSH to open a persistent connection to a list > of servers > and send them the same request. I then wrapped the module that > handles the > request with HTTP::Server::Simple::CGI that made it as a demon that > awaits > request. > > Problem: demon is a single thread request, therefore if i have 2 > requests comming > they will wait for the first to end. I have made a simple test > creating 2 is_alive requests > one sleeps for 10sec the other does not. I then restarted and send 2 > different request > and noticed that the second request awaits for the first request :( > > Q1: is there any Server like Simple I can use? instead of > HTTP::Server::Simple::CGI > > > You might want to take a look at https://metacpan.org/pod/Net::Server > or https://metacpan.org/pod/AnyEvent I have bunch of articles about them > at http://perlmaven.com/ , but most of those for paying subscribers. > >
I don't know of any self-contained servers that would solve it for you, but if you switch from blocking to non-blocking mode, that might help you even on a "simple" server. The idea is to assign a job id and launch it in the background and immediately return the job id and end the response. Then the client would need to poll some other URL to get the updates, etc. Sometimes that model works well - other times, it can be a huge friggin PITA. Depends on the use case of the client, usually. > > Q2: if i want to use apache as my web server, is there any way to > create a module > that loads once and can be accesses to all requests calling index.pl > <http://index.pl> ? > > > > As CGI I doubt. As mod_perl maybe. > Using a separate server and using Apache as a reverse proxy: most probably. I'd see what you can do with mod_rewrite. With PHP (for example, wordpress), this is exactly what they do - rewrite URLs to all go to index.php with query strings (or as-is, and then parse the URL inside the script) Yitzchak _______________________________________________ Perl mailing list [email protected] http://mail.perl.org.il/mailman/listinfo/perl
