Re: Running multiple copies of same site in ModPerl

gAzZaLi <[email protected]>
Newsgroups gmane.comp.apache.mod-perl
Message-ID <[email protected]>
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.
>>
>
>
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.