SheridanCat has asked for the wisdom of the Perl Monks concerning the following question:

A trip through Super Search didn't help much with this one, so hopefully someone has been down this road before.

We're starting to use mod_perl in our development as we expose "web services" interfaces to many of our backend systems. But I'm running into a problem that I can't figure a solution to.

We have a single Apache2 dev server. I've configured it with virtual hosts such that each developer has his/her own port. So, calling 192.168.0.100:8001 accesses my virtual host and port 8002 accesses another developer's virtual host.

Each virtual host entry has a "PerlSetEnv PERL5LIB" pointing to the /perllib directory in each developers' individual home directory, so /home/sheridancat/perllib and /home/otherguy/perllib.

In the base apache2 config file, I have the following:

PerlRequire "/etc/apache2/startup.pl" <Location /handleit> SetHandler perl-script PerlResponseHandler MyNamespace::Apache2::RequestHandler::HandleStuf +f </Location>
The problem is that which PerlResponseHandler is being called is ambiguous. It could be the version in /home/sheridancat/perllib or the one in /home/otherguy/perllib. If we're out of synch (like because one of us is working) there is frustration because the module in memory may not be the one being worked on.

My hope is that there's a way such that a call to port 8001 will grab /home/sheridancat/perllib/MyNameSpace... and a call to port 8002 will load /home/otherguy/perllib/MyNameSpace....

So, does anyone have any experience setting up mod_perl like this? Any help is appreciated.

SheridanCat

Replies are listed 'Best First'.
Re: Writing mod_perl in multi-developer environment
by clinton (Priest) on Aug 24, 2007 at 20:11 UTC
    Probably the easiest way to do it is to run separate apache servers on the same machine. Use the same binaries, but start each apache with a per-user config file. Just limit the number of children that it starts so that you don't run out of memory

    Alternatively, look at PerlOptions +Parent which was added for this purpose. From the docs:

    +Parent: Create a new parent Perl interpreter for the given VirtualHost and give it its own interpreter pool (implies the Clone option).

    A common problem with mod_perl 1.0 was the shared namespace between all code within the process. Consider two developers using the same server and each wants to run a different version of a module with the same name. This example will create two parent Perl interpreters, one for each <VirtualHost>, each with its own namespace and pointing to a different paths in @INC...

    Clint

Re: Writing mod_perl in multi-developer environment
by perrin (Chancellor) on Aug 24, 2007 at 20:49 UTC
    It can be done, but it would be much easier to simply run separate servers for everyone. Just start apache with a different httpd.conf for each developer, using different ports and log files. Then they can restart their servers if they need to without worrying about anyone else.