Re: Running multiple copies of same site in ModPerl
On 11/29/2011 10:29 PM, Nishikant Kapoor wrote: I have been running a ModPerl site fine with following configuration. The problem started when I made a complete copy of the original site and tried to run the two in the same environment. For some reason, calling up the ORIG site (http://127.0.0.1/ORIG/) now calls the COPY site at http://127.0.0.1/COPY/. None of the changes made in ORIG::MODS::base.pm are getting picked up even after restarting the apache server. However, changes to COPY::MODS::base.pm are showing up fine. The problem is that mod_perl uses the same Perl interpreter for everything (by default) and that interpreter is persistent. I'm guessing that your "package" declaration in ORIG::MODS::base.pm and COPY::MODS::base.pm are the same. Perl won't load 2 packages of the same name. The usual solutions are: 1) rename your modules so that they don't have the same package names. 2) run multiple separate apaches on the same physical server (not as hard as it seems to most people and pretty easy to do if you're running a proxy in front. And you really should be running a proxy in front). 3) Try to have multiple Perl interpreters using a different Apache MPM. I haven't seen anyone give a definitive guide to how to do this (although I could have missed something) and results seem to be mixed. I prefer #2 and use it constantly. It also makes it really easy to have separate dev environments each using their own code. -- Michael Peters Plus Three, LP
Re: Running multiple copies of same site in ModPerl
Am 30.11.2011 um 15:02 schrieb Michael Peters: > On 11/29/2011 10:29 PM, Nishikant Kapoor wrote: > >> I have been running a ModPerl site fine with following configuration. >> The problem started when I made a complete copy of the original site and >> tried to run the two in the same environment. For some reason, calling >> up the ORIG site (http://127.0.0.1/ORIG/) now calls the COPY site at >> http://127.0.0.1/COPY/. None of the changes made in ORIG::MODS::base.pm >> are getting picked up even after restarting the apache server. However, >> changes to COPY::MODS::base.pm are showing up fine. > > The problem is that mod_perl uses the same Perl interpreter for everything > (by default) and that interpreter is persistent. I'm guessing that your > "package" declaration in ORIG::MODS::base.pm and COPY::MODS::base.pm are the > same. Perl won't load 2 packages of the same name. The usual solutions are: > > 1) rename your modules so that they don't have the same package names. > > 2) run multiple separate apaches on the same physical server (not as hard as > it seems to most people and pretty easy to do if you're running a proxy in > front. And you really should be running a proxy in front). > > 3) Try to have multiple Perl interpreters using a different Apache MPM. I > haven't seen anyone give a definitive guide to how to do this (although I > could have missed something) and results seem to be mixed. > > I prefer #2 and use it constantly. It also makes it really easy to have > separate dev environments each using their own code. > You could do that too with the "+parent" option, see mod_perl docs. So you don't need another apache instance (but you need a lot of RAM ). This creates an own interpreter. But I'm not sure if it can be applied on a level or at least on Rolf Schaufelberger
RE: Installing mod_perl on Windows 7
> But try this : > At the beginning of your script, add these lines : > > use Apache::RequestRec; > > my $r=shift; > print "Hostname : ",$r->hostname,"\n"; > > if you don't get an error, and you see the line in the output, then for sure > you /are/ > running under mod_perl. I did this and it gave me an error at this line: > use Apache::RequestRec; But if I replace it by > use Apache2::RequestRec; Then the script loads without problem. I have put a BEGIN{} block in my printenv.pl script, which prints something on the screen, and it does seem to only print the first time I execute the script. So it does seem like mod_perl is indeed working. I guess the documentation on this page is not accurate then:
RE: Installing mod_perl on Windows 7
Oups... pressed the wrong key and sent it before I was done. I guess the documentation on this page is not accurate then: http://perl.apache.org/docs/1.0/guide/install.html#Testing_via_CGI_script because I'm definitely NOT seeing GATEWAY_INTERFACE=CGI-Perl/1.1 (it's CGI/1.1). Thanks a million! You have saved me hours and hours of digging around and hunting down red herrings. Alain
Re: mod_perl memory
I ran similar tests to what Torsten had, and definitely noticed a difference in memory usage, but didn't see any leaks in memory. Memory usage is about twice when using $r->print, but it does hit it's max fairly quickly. Memory usage also maxes out fairly quickly using the bucket brigade method. Maybe the leak has been fixed? I'm using apache 2.2.21 and mod_perl 2.05 Thanks, Dimitri On Thu, Mar 18, 2010 at 7:09 AM, Torsten Förtsch wrote: > On Thursday 18 March 2010 11:54:53 Mårten Svantesson wrote: > > I have never worked directly with the APR API but in the example above > > couldn't you prevent the request pool from growing by explicitly reusing > > the bucket brigade? > > > > Something like (not tested): > > > > sub { > >my ($r)=@_; > > > >my $ba=$r->connection->bucket_alloc; > >my $bb2=APR::Brigade->new($r->pool, $ba); > >until( -e '/tmp/stop' ) { > > $bb2->insert_tail(APR::Bucket->new($ba, ("x"x70)."\n")); > > $bb2->insert_tail(APR::Bucket::flush_create $ba); > > $r->output_filters->pass_brigade($bb2); > > $bb2->cleanup(); > >} > > > >$bb2->insert_tail(APR::Bucket::eos_create $ba); > >$r->output_filters->pass_brigade($bb2); > > > >return Apache2::Const::OK; > > } > > > Thanks for pointing to the obvious. This doesn't grow either. > > Torsten Förtsch > > -- > Need professional modperl support? Hire me! (http://foertsch.name) > > Like fantasy? http://kabatinte.net >
Re: Running multiple copies of same site in ModPerl
Michael Peters wrote: On 11/29/2011 10:29 PM, Nishikant Kapoor wrote: I have been running a ModPerl site fine with following configuration. The problem started when I made a complete copy of the original site and tried to run the two in the same environment. For some reason, calling up the ORIG site (http://127.0.0.1/ORIG/) now calls the COPY site at http://127.0.0.1/COPY/. None of the changes made in ORIG::MODS::base.pm are getting picked up even after restarting the apache server. However, changes to COPY::MODS::base.pm are showing up fine. The problem is that mod_perl uses the same Perl interpreter for everything (by default) and that interpreter is persistent. I'm guessing that your "package" declaration in ORIG::MODS::base.pm and COPY::MODS::base.pm are the same. Perl won't load 2 packages of the same name. The usual solutions are: I thought about that too, and so I did change the "package" declaration in ORIG::MODS::base.pm and COPY::MODS::base.pm but calling up http://127.0.0.1/ORIG/ still calls http://127.0.0.1/COPY/. Here is what each base.pm has: /var/www/perl/COPY/MODS/base.pm: package COPY::MODS::base; /var/www/perl/ORIG/MODS/base.pm: package ORIG::MODS::base; And, as gAzZaLi suggested, I also tried switching the order of the ORIG and COPY lines in startup.pl, and I could see the changes made in ORIG but not the changes in COPY. So, COPY indeed is overriding ORIG. As for the #2 mentioned below, are there any pointers that you could refer to? Thanks, Nishi 1) rename your modules so that they don't have the same package names. 2) run multiple separate apaches on the same physical server (not as hard as it seems to most people and pretty easy to do if you're running a proxy in front. And you really should be running a proxy in front). 3) Try to have multiple Perl interpreters using a different Apache MPM. I haven't seen anyone give a definitive guide to how to do this (although I could have missed something) and results seem to be mixed. I prefer #2 and use it constantly. It also makes it really easy to have separate dev environments each using their own code.
Re: Running multiple copies of same site in ModPerl
Hello, What you're doing is not recommended as you run into namespace issues. Perl caches files and modules that were loaded in %INC, so if you have files and modules with the same name, only one of them gets loaded. Possibly, as an exercise, if you switch the order of the ORIG and COPY lines in your startup.pl, you'll see the changes you've made in ORIG and not the changes in COPY. I've made the assumption here that your site is more than just the one base.pm file and both base.pm packages use other packages with the same names. Suppose your ORIG::mods::base.pm has "use mods::somepackage" and COPY::mods::base.pm has "use mods::somepackage", with the startup.pl file, Perl will load only the .../perl/COPY/mods/somepackage.pm file. If however your site is just the base.pm file, and the package declaration is as you've written, my answer is off. Good luck. g. On 11/29/2011 7:29 PM, Nishikant Kapoor wrote: Hello List, I have been running a ModPerl site fine with following configuration. The problem started when I made a complete copy of the original site and tried to run the two in the same environment. For some reason, calling up the ORIG site (http://127.0.0.1/ORIG/) now calls the COPY site at http://127.0.0.1/COPY/. None of the changes made in ORIG::MODS::base.pm are getting picked up even after restarting the apache server. However, changes to COPY::MODS::base.pm are showing up fine. Would appreciate any help. Here is what I have in the config: /etc/httpd/conf/httpd.conf: --- PerlRequire /var/www/perl/startup.pl SetHandler perl-script PerlResponseHandler ORIG::MODS::base SetHandler perl-script PerlResponseHandler COPY::MODS::base /var/www/perl/startup.pl: - use lib qw(/var/www/perl); use lib qw(/var/www/perl/ORIG); use lib qw(/var/www/perl/COPY); 1; Apache/2.2.14 (Mandriva Linux/PREFORK-1mdv2010.0) apache-mod_perl-2.0.4-11mdv2010.0 This is perl, v5.10.1 (*) built for x86_64-linux-thread-multi Thanks, Nishi
Re: Running multiple copies of same site in ModPerl
My point about switching the lines in startup.pl was to give you a better understanding of what was going on. It was not intended as a fix. Looks like you've got your base.pm package declaration right. But for your sites to work as intended, you've got to do that for all the modules in /ORIG/mods and /COPY/mods, not just the response handler. And then you have to change all the code that once refered to "mods::something" to "ORIG::mods::something" and same for COPY. But please do NOT do this as it's a bad idea and leads to premature aging. If you're interested further in the namespace issue, check this out from the Practial mod_perl book: http://modperlbook.org/html/6-3-Namespace-Issues.html As for a good solution, which I forgot to mention but others have, go with #2 -- setting up separate instances of Apache on the same physical server. The Practical mod_perl book has information on multiple server setups too and good points to consider when running separate dev, staging and production servers. On 11/30/2011 10:15 AM, Nishikant Kapoor wrote: Michael Peters wrote: On 11/29/2011 10:29 PM, Nishikant Kapoor wrote: I have been running a ModPerl site fine with following configuration. The problem started when I made a complete copy of the original site and tried to run the two in the same environment. For some reason, calling up the ORIG site (http://127.0.0.1/ORIG/) now calls the COPY site at http://127.0.0.1/COPY/. None of the changes made in ORIG::MODS::base.pm are getting picked up even after restarting the apache server. However, changes to COPY::MODS::base.pm are showing up fine. The problem is that mod_perl uses the same Perl interpreter for everything (by default) and that interpreter is persistent. I'm guessing that your "package" declaration in ORIG::MODS::base.pm and COPY::MODS::base.pm are the same. Perl won't load 2 packages of the same name. The usual solutions are: I thought about that too, and so I did change the "package" declaration in ORIG::MODS::base.pm and COPY::MODS::base.pm but calling up http://127.0.0.1/ORIG/ still calls http://127.0.0.1/COPY/. Here is what each base.pm has: /var/www/perl/COPY/MODS/base.pm: package COPY::MODS::base; /var/www/perl/ORIG/MODS/base.pm: package ORIG::MODS::base; And, as gAzZaLi suggested, I also tried switching the order of the ORIG and COPY lines in startup.pl, and I could see the changes made in ORIG but not the changes in COPY. So, COPY indeed is overriding ORIG. As for the #2 mentioned below, are there any pointers that you could refer to? Thanks, Nishi 1) rename your modules so that they don't have the same package names. 2) run multiple separate apaches on the same physical server (not as hard as it seems to most people and pretty easy to do if you're running a proxy in front. And you really should be running a proxy in front). 3) Try to have multiple Perl interpreters using a different Apache MPM. I haven't seen anyone give a definitive guide to how to do this (although I could have missed something) and results seem to be mixed. I prefer #2 and use it constantly. It also makes it really easy to have separate dev environments each using their own code.