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 09:56:04 UTC
Multiple virtual hosts and same pm-modules names errors
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):
------------------------
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
Re[2]: Multiple virtual hosts and same pm-modules names errors
Posted by Alexander Shipitsyn <sh...@omsu.ru>.
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 "Dr. Helmut Zeilinger" <ma...@hzlabs.com>.
Hi Alexander,
do you have a threaded Perl interpreter?
I also use
..
PerlOptions +Parent
..
but in the vhost-config files (which should make no difference?)
and in the startup files of vhost 1
..
use lib /path1/lib.pm
..
and in the startup file of vhost 2
..
use lib /path2/lib.pm
..
This works for me.
Both lib.pm's are separated because new perl interpreters are used for
vhost1 and vhost2.
Helmut
--On Friday, January 23, 2004 14:56:04 +0600 Alexander Shipitsyn
<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
>
>
---------------------------------------------------------------------
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 Stuart Johnston <sj...@vaultranet.com>.
Alexander Shipitsyn wrote:
>
> I need to have different code (and same module names!) for production
> and development site.
>
> Also I need to have (for example) two different production sites
> (production sites for company A and company B) (site-A-production and
> site-B-production), developed with same module naming conventions (for
> example, each production site (A and B) have pm-module with name
> "Tools.pm" and different code of each Tools.pm). For example, my
> programming style is to use in web-pages my service module named
> "Tools.pm" developed specially for each site.
>
> And for each of production sites (A and B) I need to have development
> version of site (site-A-dev and site-B-dev) with different code of
> modules.
>
Do you really think it is a good idea to have your production and
development running in the same httpd? I understand you may have
specific restrictions but get around this if you can.
>
> Ok, general question about hosting multiple sites (virtual hosts).
> ==================================================================
>
> Assume that I need to host 10 (or 50) Apache::ASP-based sites. Assume
> that each site have private module "Tools.pm" with globally-unique
> code. Assume that I need to have one httpd build configured for
> processing by child-httpd more than 1 user request (user request for
> random hosted site). Assume that I need to use only one IP-address and
> only port 80 on this IP-address with one httpd build (one root
> instance in memory with 10 child processes).
How flexible is your one root httpd requirement? If you can bend this a
little, one option would be to have one apache running on your IP:80
serving static content for all sites (such as images) and also acting as
a front-end proxy for your apache/mod_perl servers. You would have one
mod_perl instance per site but they would not need to bind to an
external IP, each would run on a different local port (localhost:8000,
locahost:8001, etc).
http://perl.apache.org/docs/1.0/guide/scenario.html#Front_end_Back_end_Proxying_with_Virtual_Hosts
HTH,
Stuart Johnston
--
http://VaultraNet.com
---------------------------------------------------------------------
To unsubscribe, e-mail: asp-unsubscribe@perl.apache.org
For additional commands, e-mail: asp-help@perl.apache.org
Re[2]: Multiple virtual hosts and same pm-modules names errors
Posted by Alexander Shipitsyn <sh...@omsu.ru>.
Hello!
Friday, January 23, 2004, 3:59:09 PM, you wrote:
>> 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.
RF> This applies to asp pages because they are wrapped in a subroutine,
RF> "my" variables then become local to the current request. This
RF> doesn't apply to "my" variables of modules. Additionally, perl will
RF> always load the same module (first one it finds in traveling @INC) if
RF> there are duplicates.
.htaccess for site1:
SetEnv PERL5LIB /home/omsu/site/lib/pm
.htaccess for site2:
SetEnv PERL5LIB /home/omsutech/site/lib/pm
These directives allows to mod_perl/Apache::ASP mix up modules with
same names from different directories ???
See also my questions later in this text.
RF> Here's a possible solution:
RF> Make your module object oriented and put the module variables in an
RF> object instance. Store the object instance in your Application or
RF> Session hash, whichever applies.
RF> package MyTools;
RF> #my %cache = (); #NO,NO,NO becomes global in httpd child process
RF> sub new
RF> {
RF> my %cache = (); #local to the sub, ok
RF> return bless {cache => \%cache}, shift;
RF> }
RF> Now you can create separate instances by coding:
RF> my $obj1 = MyTools->new();
RF> my $obj2 = MyTools->new();
RF> Now, each object gets its own cache. If you want a single object
RF> to share across the entire application then create it in
RF> Application_OnStart (global.asa) and keep a reference in the
RF> $Application object.
RF> In this scenario both sites will have separate data but share the same code.
RF> If your going to do development also on the modules this is not enough
RF> because you are also affecting the production site. Instead you should run
RF> a separate httpd for the development site. I find it often necessary to
RF> restart or reload httpd during development so for me a that is the
RF> obvious choice.
Thanks, Robert!
But... Let:
I need to have different code (and same module names!) for production
and development site.
Also I need to have (for example) two different production sites
(production sites for company A and company B) (site-A-production and
site-B-production), developed with same module naming conventions (for
example, each production site (A and B) have pm-module with name
"Tools.pm" and different code of each Tools.pm). For example, my
programming style is to use in web-pages my service module named
"Tools.pm" developed specially for each site.
And for each of production sites (A and B) I need to have development
version of site (site-A-dev and site-B-dev) with different code of
modules.
Ok, general question about hosting multiple sites (virtual hosts).
==================================================================
Assume that I need to host 10 (or 50) Apache::ASP-based sites. Assume
that each site have private module "Tools.pm" with globally-unique
code. Assume that I need to have one httpd build configured for
processing by child-httpd more than 1 user request (user request for
random hosted site). Assume that I need to use only one IP-address and
only port 80 on this IP-address with one httpd build (one root
instance in memory with 10 child processes).
How to solve this problem with modules mixing in this case ???
>> -----Original Message-----
>> From: Alexander Shipitsyn [mailto:ship@omsu.ru]
>> Sent: Friday, January 23, 2004 9:56 AM
>> To: asp@perl.apache.org
>> Subject: Multiple virtual hosts and same pm-modules names errors
>>
>>
>> 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):
>> ------------------------
>> 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
RF> ---------------------------------------------------------------------
RF> To unsubscribe, e-mail: asp-unsubscribe@perl.apache.org
RF> For additional commands, e-mail: asp-help@perl.apache.org
--
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 Robert Friberg <ro...@ensofus.se>.
> 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.
This applies to asp pages because they are wrapped in a subroutine,
"my" variables then become local to the current request. This
doesn't apply to "my" variables of modules. Additionally, perl will
always load the same module (first one it finds in traveling @INC) if
there are duplicates.
Here's a possible solution:
Make your module object oriented and put the module variables in an
object instance. Store the object instance in your Application or
Session hash, whichever applies.
package MyTools;
#my %cache = (); #NO,NO,NO becomes global in httpd child process
sub new
{
my %cache = (); #local to the sub, ok
return bless {cache => \%cache}, shift;
}
Now you can create separate instances by coding:
my $obj1 = MyTools->new();
my $obj2 = MyTools->new();
Now, each object gets its own cache. If you want a single object
to share across the entire application then create it in
Application_OnStart (global.asa) and keep a reference in the
$Application object.
In this scenario both sites will have separate data but share the same code.
If your going to do development also on the modules this is not enough
because you are also affecting the production site. Instead you should run
a separate httpd for the development site. I find it often necessary to
restart or reload httpd during development so for me a that is the
obvious choice.
hth,
------------------------------------------------------------------------
! Robert Friberg 0733-839080
! Developer/Trainer perl,java,dotnet,linux,xml,uml,sql,c/c++,vb
! Ensofus AB http://www.ensofus.se/
! Miljo Online AB http://www.miljo-online.se/
------------------------------------------------------------------------
> -----Original Message-----
> From: Alexander Shipitsyn [mailto:ship@omsu.ru]
> Sent: Friday, January 23, 2004 9:56 AM
> To: asp@perl.apache.org
> Subject: Multiple virtual hosts and same pm-modules names errors
>
>
> 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):
> ------------------------
> 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
---------------------------------------------------------------------
To unsubscribe, e-mail: asp-unsubscribe@perl.apache.org
For additional commands, e-mail: asp-help@perl.apache.org