This is a discussion on Re: duplicate trees, different handlers - modperl ; Matthew wrote: > Hey gang, happy friday! > > We have two trees for our web app: > > Prod -> /pages/sc2/roomlogin? > PreProd -> /pages/sctest/roomlogin? > > httpd.conf: > > Location /pages/sc2/roomlogin -> /path/pages/sctest/omno/prod.pm > Location /pages/sctest/roomlogin -> /path/pages/sctest/omno/preprod.pm ...
> Hey gang, happy friday!
> We have two trees for our web app:
> Prod -> /pages/sc2/roomlogin?
> PreProd -> /pages/sctest/roomlogin?
> Location /pages/sc2/roomlogin -> /path/pages/sctest/omno/prod.pm
> Location /pages/sctest/roomlogin -> /path/pages/sctest/omno/preprod.pm
> After testing is done on preprod, we migrate from preprod to prod.
> The problem I am facing is that when we migrate, I have copy preprod.pm
> to prod.pm and make a change in the package name.
> I'm thinking if I change my @lib to one /path/pages/ then I can do
> something like this:
> SetHandler perl-script
> PerlResponseHandler sc2:mno::secconf
> SetHandler perl-script
> PerlResponseHandler sctest:mno::secconf
> That way both perl files will have the same package (omno::secconf) but
> be in two separate locations to facilitate easy migration.
> Is my theory correct? If not, have others been in a situation like this?
> Any/all assistance is greatly appreciated.
I don't think this will work. When looking up a module, Perl will use the
package name you specify to find which file to load. Then it makes an entry in
%INC indicating which file was found for that package. So far so good.
So in your above scenario sc2:mno::secconf and sctest:mno::secconf would
have separate entries in %INC, but their entries would not be for omno::secconf,
so if any code tried to use omno::secconf it would have to try and re-load it
and then it would fail. If this is the only module your application is using,
then that's not too bad, but this same problem goes for any of your modules.
Not only that, but Perl only has one place in it's symbol tables for packages,
etc. So when apache loads up those modules, the last one loaded wins for the
omno::secconf location. You can never have more than on module/package of the
same name loaded at anyone time.
The easiest solution is to just run 2 apaches. Configure pre-prod for a
different port. You can even run them from the same apache binary, just give
them different configs to start off.
httpd -f conf/httpd.conf
httpd -f conf/preprod-httpd.conf
Plus Three, LP