Re: modperl and comet?
E R schrieb am 16.04.2010 um 15:37:44 (-0500): [modperl and comet?] > I'm interested in adding a Comet capability to a (rather large) > mod-perl application. > > To get around XSS limitations, the Comet service will have the > same host and port as the web service. However, I don't want a > large mod-perl process tied up performing the Comet service. > > Is there a way that a web request can be passed off to another > process without tying up the Apache process? For instance, can > the Apache process pass the file descriptors for the HTTP > connection to another process which would free itself up for > handling the next Apache request? I don't know how you could do that. Your mod_perl process could certainly send the response to a reverse proxy, but then it would be out of the business of servicing the request. > Is there another way to implement this? I'm rather clueless as to how to implement this myself, but it appears to me (maybe only due to limited knowledge) that unless you want to have one process tied up to servicing one client, you need non-blocking IO, like Danga::Socket (basically undocumented), or AnyEvent, and possibly other modules by Marc Lehmann. If anyone has ever done any such programming, I'd be curious how to get started, conceptually. -- Michael Ludwig
[PerlMapToStorageHandler] Basic URI to File translation example
PerlMapToStorageHandler I would like to use the PerlMapToStorageHandler to translate a URI file request into a Filesystem file request. I have a couple functions to check and see if a file exists, and if not, then copy it from a remote server locally before allowing the request to go to the next phase. Basic gist of what I want to handle in the PerlMapToStorageHandler is: 1) Client makes a request to server for /package_20.zip 2) My handler: gets the filename from the URI (no problem here) maps the filename to a real file on the file system checks to make sure the file exists File does not exist: copy file from another location to destination properly MapToStorage, and let the next phase take place File exists: properly MapToStorage, and let the next phase take place 3) Client receives file
Re: [PerlMapToStorageHandler] Basic URI to File translation example
On Saturday 17 April 2010 18:32:13 Robert Smith wrote: > PerlMapToStorageHandler > > I would like to use the PerlMapToStorageHandler to translate a URI file > request into a Filesystem file request. I have a couple functions to check > and see if a file exists, and if not, then copy it from a remote server > locally before allowing the request to go to the next phase. > > > > Basic gist of what I want to handle in the PerlMapToStorageHandler is: > > 1) Client makes a request to server for /package_20.zip > > 2) My handler: > gets the filename from the URI (no problem here) > maps the filename to a real file on the file system > checks to make sure the file exists > > File does not exist: > copy file from another location to destination > properly MapToStorage, and let the next phase > take place > > > > File exists: > properly MapToStorage, and let the next phase > take place > > 3) Client receives file > The only thing to watch out here is either to fill in $r->finfo+$r->path_info correctly or to return DECLINED and have the core m2s handler done it. $r- >filename is normally set by the translation handler. The core trans handler does just $r->document_root.$r->uri. You can change that if you need. The core m2s handler also looks for .htaccess and applies and blocks. So better to return DECLINED from your handler. Otherwise the AAA phases might not do what you want. Have you thought about mod_proxy+mod_cache to solve the problem? Torsten Förtsch -- Need professional modperl support? Hire me! (http://foertsch.name) Like fantasy? http://kabatinte.net
Apache::DBI connect_on_init problem
Hello, I'm trying to prestart db connection. But Apache::DBI->connect_on_init is not working. Gives no error, but db connection is not made. Setting $Apache::DBI::DEBUG = 2 indicates that ChildInitHandler runs. I tried to create my custom ChildInitHandler and start db connection from it but it also has no effect. It also seems as if the handler was silently aborted after the connect call. I inserted debugging print before and after the connect call. In the Postgres log I can see a connection made and immediately terminated. So now I'm quite helpless as what to do.
Re: Apache::DBI connect_on_init problem
On 04/17/10 14:27, Jiri Pavlovsky wrote: Hello, I'm trying to prestart db connection. But Apache::DBI->connect_on_init is not working. Gives no error, but db connection is not made. Setting $Apache::DBI::DEBUG = 2 indicates that ChildInitHandler runs. I tried to create my custom ChildInitHandler and start db connection from it but it also has no effect. It also seems as if the handler was silently aborted after the connect call. I inserted debugging print before and after the connect call. In the Postgres log I can see a connection made and immediately terminated. So now I'm quite helpless as what to do. I use Apache::DBI and connect_on_init. What are your full details? Using startup.pl? what values for initial connection?
Re: Apache::DBI connect_on_init problem
On 17.4.2010 22:22, Chris Bennett wrote: On 04/17/10 14:27, Jiri Pavlovsky wrote: Hello, I'm trying to prestart db connection. But Apache::DBI->connect_on_init is not working. Gives no error, but db connection is not made. Setting $Apache::DBI::DEBUG = 2 indicates that ChildInitHandler runs. I tried to create my custom ChildInitHandler and start db connection from it but it also has no effect. It also seems as if the handler was silently aborted after the connect call. I inserted debugging print before and after the connect call. In the Postgres log I can see a connection made and immediately terminated. So now I'm quite helpless as what to do. I use Apache::DBI and connect_on_init. What are your full details? Using startup.pl? what values for initial connection? Hello, my start-up.pl below. I try to setup two connections. In Apache log I see several lines like: 13121 Apache::DBI PerlChildInitHandler 13121 Apache::DBI push PerlChildExitHandler No errors. But in Postgres log I can see several very short connections as the first user. So maybe it is connecting and then it quits? Thats all I could find out. Thanks -- #!/usr/bin/perl -w use strict; use Apache::DBI; $Apache::DBI::DEBUG = 2; DBI->install_driver("Pg"); Apache::DBI->connect_on_init("dbi:Pg:dbname=p69", "user", "pass", { PrintError => 1, # warn() on errors RaiseError => 0, # don't die on error AutoCommit => 1, # commit executes immediately pg_enable_utf8 => 1, } ); Apache::DBI->connect_on_init("dbi:Pg:dbname=p69", "another", "pass", { PrintError => 1, # warn() on errors RaiseError => 0, # don't die on error AutoCommit => 1, # commit executes immediately pg_enable_utf8 => 1, } );
Re: Apache::DBI connect_on_init problem
On Sat, Apr 17, 2010 at 1:09 PM, Jiri Pavlovsky wrote:> Apache::DBI->connect_on_init("dbi:Pg:dbname=p69", > "user", > "pass", > { > PrintError => 1, # warn() on errors > RaiseError => 0, # don't die on error > AutoCommit => 1, # commit executes immediately > pg_enable_utf8 => 1, > } > ); > > Apache::DBI->connect_on_init("dbi:Pg:dbname=p69", > "another", > "pass", > { > PrintError => 1, # warn() on errors > RaiseError => 0, # don't die on error > AutoCommit => 1, # commit executes immediately > pg_enable_utf8 => 1, > } > ); Why do you call connect_on_init twice with different parameters? If anything stands out as causing the problem, that would come to my mind as the first thing.
Re: Apache::DBI connect_on_init problem
On 04/17/10 15:09, Jiri Pavlovsky wrote: On 17.4.2010 22:22, Chris Bennett wrote: On 04/17/10 14:27, Jiri Pavlovsky wrote: Hello, I'm trying to prestart db connection. But Apache::DBI->connect_on_init is not working. Gives no error, but db connection is not made. Setting $Apache::DBI::DEBUG = 2 indicates that ChildInitHandler runs. I tried to create my custom ChildInitHandler and start db connection from it but it also has no effect. It also seems as if the handler was silently aborted after the connect call. I inserted debugging print before and after the connect call. In the Postgres log I can see a connection made and immediately terminated. So now I'm quite helpless as what to do. I use Apache::DBI and connect_on_init. What are your full details? Using startup.pl? what values for initial connection? Hello, my start-up.pl below. I try to setup two connections. In Apache log I see several lines like: 13121 Apache::DBI PerlChildInitHandler 13121 Apache::DBI push PerlChildExitHandler No errors. But in Postgres log I can see several very short connections as the first user. So maybe it is connecting and then it quits? Thats all I could find out. Thanks -- #!/usr/bin/perl -w use strict; use Apache::DBI; $Apache::DBI::DEBUG = 2; DBI->install_driver("Pg"); Apache::DBI->connect_on_init("dbi:Pg:dbname=p69", "user", "pass", { PrintError => 1, # warn() on errors RaiseError => 0, # don't die on error AutoCommit => 1, # commit executes immediately pg_enable_utf8 => 1, } ); Apache::DBI->connect_on_init("dbi:Pg:dbname=p69", "another", "pass", { PrintError => 1, # warn() on errors RaiseError => 0, # don't die on error AutoCommit => 1, # commit executes immediately pg_enable_utf8 => 1, } ); Oh, this is your error. You may only use Apache::DBI_connect_on_init for ONE connection, which stays up and running. Use your more important one (for speed) for this. You may also have other connections, but these will reconnect-disconnect each time Use the following for those: tack in a dbi_connect_method => 'connect' for these other ones
Re: Apache::DBI connect_on_init problem
On 17.4.2010 22:42, Chris Bennett wrote: Oh, this is your error. You may only use Apache::DBI_connect_on_init for ONE connection, which stays up and running. Use your more important one (for speed) for this. This doesn't seem to make difference. It doesn't work even when making only one connection. The connection is not made. I wanted to make two, because I have two apps. One is frequently used and so the db connection is made from the app short after spawning the child anyway. The other one is seldom so there is a overhead every time request comes. What seems to work though is to create both connection sin the first app.
Re: Apache::DBI connect_on_init problem
On 17.4.2010 23:21, Jiri Pavlovsky wrote: On 17.4.2010 22:42, Chris Bennett wrote: Oh, this is your error. You may only use Apache::DBI_connect_on_init for ONE connection, which stays up and running. Use your more important one (for speed) for this. This doesn't seem to make difference. It doesn't work even when making only one connection. The connection is not made. I wanted to make two, because I have two apps. One is frequently used and so the db connection is made from the app short after spawning the child anyway. The other one is seldom so there is a overhead every time request comes. What seems to work though is to create both connection sin the first app. UPDATE: My problem was solved by upgrading Apache::DBI to 1.08. Yes, I should have done that first. I can even make two connections from startup.pl.