You are viewing a plain text version of this content. The canonical link for it is here.
Posted to asp@perl.apache.org by Alexander Shipitsyn <sh...@omsu.ru> on 2004/01/23 11:56:38 UTC

Re[2]: Multiple virtual hosts and same pm-modules names errors

Hello!

Friday, January 23, 2004, 3:35:21 PM, you wrote:

DHZ> do you have a threaded Perl interpreter?

Yes, threaded; static linked into httpd daemon.



DHZ> I also use
DHZ> ..
DHZ> PerlOptions +Parent
DHZ> ..

DHZ> but in the vhost-config files (which should make no difference?)

DHZ> and in the startup files of vhost 1

DHZ> ..
DHZ> use lib /path1/lib.pm
DHZ> ..

DHZ> and in the startup file of vhost 2

DHZ> ..
DHZ> use lib /path2/lib.pm
DHZ> ..

DHZ> This works for me.
DHZ> Both lib.pm's are separated because new perl interpreters are used for
DHZ> vhost1 and vhost2.

Thanks Helmut, I will try this solution (PerlOptions +Parent) later, after
learning this option of mod_perl...




DHZ> Helmut

DHZ> --On Friday, January 23, 2004 14:56:04 +0600 Alexander Shipitsyn 
DHZ> <sh...@omsu.ru> wrote:

>> Hello!
>>
>> I have problem with caching of compiled my .pm modules (auto-compiled
>> in memory by Apache::ASP and mod_perl) with same names for different
>> sites on same Apache::ASP/apache machine.
>>
>> I have 2 virtual hosts:
>>
>>   "site1" is for production site
>>   (homedir is .../site1)
>>
>>     and
>>
>>   "site2" is for developing site.
>>   (homedir is .../site2)
>>
>> Homedirs are different.
>>
>> I copied all files of site "site1" to home directory of site "site2"
>> (Apache::ASP is configured via .htaccess files located in different
>> site1 and site2 home directories).
>>
>> Let my http-request-1 for site1 hit on apache-child-process-A and then
>> my http-request-2 for site2 hit on same apache-child-process-A
>> (apache-child-process-A processes multiple requests before die of
>> apache-child-process-A).
>>
>> During process of http-request-2 for site2, apache-child-process-A
>> uses cache of my module Tools.pm from site1. This is some error for
>> me!!! In fact, pm-module for site1 is used on site2 and module for site2
>> is not used.
>>
>> If each apache-child-process processes only 1 request and then die,
>> then all is Ok, no error occurs.
>>
>> I known about issue "Why do variables retain their values between
>> requests?" in FAQ and I always use my()/local() for not retain values
>> of variables between requests. I have no problem with retain of
>> variable values between requests. I have problem with messing modules
>> with same names by Apache::ASP or/and by mod_perl.
>>
>> If I change all names of used modules for site2 (e.g. Tools.pm ->
>> Tools2.pm) or (seems to me; I not sure) change name of directory of
>> site2 where Tools.pm is located inside of site2 root, then no errors
>> occurs with using modules with same names in site1 and site2 code.
>> This is bad method for avoid described error.
>>
>> I have not special pre-compiled modules; all my pm-modules exists only
>> in sources like Tools.pm.
>>
>>
>> My .htaccess settings is (selected): PerlOptions +Parent

>> ------------------------
>> PerlSetVar NoState 0
>> PerlSetVar NoCache 1
>> PerlSetVar StatINC 1
>> PerlSetVar UseStrict 1
>>
>> PerlSetVar StateDir /tmp/omsu_asp
>> (^-- for site1)
>>
>> PerlSetVar StateDir /tmp/omsutech_asp
>> (^-- for site2)
>> ------------------------
>> Note: StateDir is different for site1 and site2
>>
>>
>>
>> My Tools.pm begin is:
>> -----------------
>> package omtools;
>> use strict;
>> require Exporter;
>> our @ISA = qw(Exporter);
>> our @EXPORT = qw(sq utf8to1251 win1251toutf8 alltrim unicode2win);
>> use Unicode::MapUTF8 qw(from_utf8 to_utf8);
>> use Unicode::Map;
>> use String::Strip;
>> use XML::DOM;
>>
>> sub bla-bla-bla...
>>
>> 1;
>> -----------------
>>
>>
>>
>> Using of my modules in pages code is:
>> --------------------
>> use locale;
>> use POSIX;
>> use Time::localtime qw(localtime);
>>
>> use omtools;
>> use sysvar;
>> use funcs;
>>
>> use XML::DOM;
>>
>> setlocale(LC_CTYPE, "ru_RU.cp1251");
>>
>> my $time_start = ctime(time);
>>
>> bla-bla-bla
>> -----------------
>> Note: my pm-modules is omtools, sysvarm, funcs
>>
>>
>>
>> Help me to solve this problem!
>>
>> (My main task at this stage is make full clone of site1 on same
>> Apache::ASP/apache engine)
>>
>>
>> Thanks!

-- 
Best regards,
 Alexander                            mailto:ship@omsu.ru


---------------------------------------------------------------------
To unsubscribe, e-mail: asp-unsubscribe@perl.apache.org
For additional commands, e-mail: asp-help@perl.apache.org


Re: Multiple virtual hosts and same pm-modules names errors

Posted by Helmut Zeilinger <ma...@hzlabs.com>.
Hi all,

>> DHZ> use lib /path1/lib.pm
>> DHZ> ..
>>
>> DHZ> and in the startup file of vhost 2
>>
>> DHZ> ..
>> DHZ> use lib /path2/lib.pm
>> DHZ> ..
>>
>> DHZ> This works for me.
>> DHZ> Both lib.pm's are separated because new perl interpreters are used
>> for DHZ> vhost1 and vhost2.
>>
>> Thanks Helmut, I will try this solution (PerlOptions +Parent) later,
>> after learning this option of mod_perl...
>>
>
> I didn't realize that +Parent worked yet for the newer threaded
> apache/mod_perl.
>

It really works! (Apache 2.48, mp 1.99_10 - ok not the newest, Perl 5.9.0 
with ithreads)

Here is my test configuration:

vhost1.conf:
..
    PerlOptions +Parent
    PerlRequire /www/hz1/conf/startup.pl
    PerlModule  Apache::ASP
..

/www/hz1/conf/startup.pl:
..
use lib '/www/hz1/lib';
..

/www/hz1/lib/TestLib:

package TestLib;
..
sub which_lib {
    return "lib1";
}
..

/www/hz1/test.asp:
<%
use TestLib;
print which_lib();
%>

vhost2.conf:
..
    PerlOptions +Parent
    PerlRequire /www/hz2/conf/startup.pl
    PerlModule  Apache::ASP
..

/www/hz2/conf/startup.pl:
..
use lib '/www/hz2/lib';
..

/www/hz2/lib/TestLib:

package TestLib;
..
sub which_lib {
    return "lib2";
}
..

/www/hz2/test.asp:
<%
use TestLib;
print which_lib();
%>

Results:

http://vhost1/test.asp     prints out 'lib1'
and
http://vhost2/test.asp     prints out 'lib2'

when you comment out the +Parent Option both are printing out 'lib1' 
(bescause vhost1 comes before vhost2 in my config file),
when you change the order both are printing 'lib2'.


Regards Helmut













---------------------------------------------------------------------
To unsubscribe, e-mail: asp-unsubscribe@perl.apache.org
For additional commands, e-mail: asp-help@perl.apache.org


Re: Multiple virtual hosts and same pm-modules names errors

Posted by Josh Chamas <jo...@chamas.com>.
> DHZ> use lib /path1/lib.pm
> DHZ> ..
> 
> DHZ> and in the startup file of vhost 2
> 
> DHZ> ..
> DHZ> use lib /path2/lib.pm
> DHZ> ..
> 
> DHZ> This works for me.
> DHZ> Both lib.pm's are separated because new perl interpreters are used for
> DHZ> vhost1 and vhost2.
> 
> Thanks Helmut, I will try this solution (PerlOptions +Parent) later, after
> learning this option of mod_perl...
> 

I didn't realize that +Parent worked yet for the newer threaded apache/mod_perl.

If this method does not work out, you can also try running the code each request
like:

  do /path2/lib.pm

or turning it into an include that you execute each request, say MyTools.inc,
and then $Response->Include it in Script_OnStart.

Regards,

Josh
________________________________________________________________
Josh Chamas, Founder                   phone:925-552-0128
Chamas Enterprises Inc.                http://www.chamas.com
NodeWorks Link Checker                 http://www.nodeworks.com


---------------------------------------------------------------------
To unsubscribe, e-mail: asp-unsubscribe@perl.apache.org
For additional commands, e-mail: asp-help@perl.apache.org


Re: StateDB to DBI/RDBMS for load balancing

Posted by Josh Chamas <jo...@chamas.com>.
Francesco Pasqualini wrote:
> to run ApacheASP application in a load balancing multi server environment we
> need the possibility to store the State in a place accessible from any
> server.
> 
> I don't like very much the NFS solution, I think it could be better to use a
> DB and so I ask to Joshua and the apacheAsp community the possibility to add
> the support for storing StateDB in a DB via DBI.
> 

Right, don't do the NFS if you can help it merely because NFS does not seem
to support the file locking semantics.  Until Apache::ASP::Session is supported
in RDBMS natively, I would use Apache::Session, which you can easily configure
to use by setting

   PerlSetVar AllowSessionState Off

and then setting $Session to the Apache::Session object created in Script_OnStart.
Make sure to do a $Server->RegisterCleanup to properly DESTROY the $Session object,
and register it in Script_OnStart immediately after creating the object.

The biggest problems here is that you do not get the benefits of Session_OnStart
and Session_OnEnd, as well as expires session garbage collection.

Regards,

Josh
________________________________________________________________
Josh Chamas, Founder                   phone:925-552-0128
Chamas Enterprises Inc.                http://www.chamas.com
NodeWorks Link Checker                 http://www.nodeworks.com


---------------------------------------------------------------------
To unsubscribe, e-mail: asp-unsubscribe@perl.apache.org
For additional commands, e-mail: asp-help@perl.apache.org


StateDB to DBI/RDBMS for load balancing

Posted by Francesco Pasqualini <f....@cpsinformatica.it>.
to run ApacheASP application in a load balancing multi server environment we
need the possibility to store the State in a place accessible from any
server.

I don't like very much the NFS solution, I think it could be better to use a
DB and so I ask to Joshua and the apacheAsp community the possibility to add
the support for storing StateDB in a DB via DBI.


thanks



---------------------------------------------------------------------
To unsubscribe, e-mail: asp-unsubscribe@perl.apache.org
For additional commands, e-mail: asp-help@perl.apache.org