You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Chris Faust <cf...@doyougot.com> on 2004/04/18 16:27:12 UTC
Defining specific vars in conf for a shared script
Hello,
I'm having a hard time figuring out a approach to what I thought would be a simple thing, but after reading a bit through the docs I'm more confused now and was hoping to get some advise.
What I want to do is have a single mp2 script service multiple virtual hosts, in order to do this I'd need to set some specific settings related to that virtual host which I can then retrieve from the mp2 script - being able to set something like a hash in the conf for each virtualhost and then have access to all those keys and values would be perfect.
For a example, I use HTML template, in my script I define the location of all my templates:
$ENV{'HTML_TEMPLATE_ROOT'} = "/websites/domain1/templates";
I want that to become something like
$ENV{'HTML_TEMPLATE_ROOT'} = $settings{'this_path_was_defined_in_the_conf_for_this_vh'};
So now that line is good for all the virtualhosts.
Thanks
-Chris
Re: Refreshing Caches at server restart
Posted by Geoffrey Young <ge...@modperlcookbook.org>.
MARTIN MOSS wrote:
> All,
>
> I have a few modules which cache a few arrays. I want to get around the
> problem of these arrays staying cached when Apache Restarts gracefully. I
> can't have the server stop and start, and Apache::Reload isn't really the
> solution for this problem (or at least I don't think it is).
>
> Has anybody done something which can allow me to force certain modules to
> reload/refresh whenever Apache does a Graceful restart?
try a PerlRestartHandler.
--Geoff
--
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html
Refreshing Caches at server restart
Posted by MARTIN MOSS <ma...@btopenworld.com>.
All,
I have a few modules which cache a few arrays. I want to get around the problem of these arrays staying cached when Apache Restarts gracefully. I can't have the server stop and start, and Apache::Reload isn't really the solution for this problem (or at least I don't think it is).
Has anybody done something which can allow me to force certain modules to reload/refresh whenever Apache does a Graceful restart?
Marty
Chris Faust <cf...@doyougot.com> wrote:Thanks Geoffrey,
That is exactly what I wanted to know.
-Chris
----- Original Message -----
From: "Geoffrey Young"
To: "Chris Faust"
Cc: "Tom Schindl" ;
Sent: Sunday, April 18, 2004 1:23 PM
Subject: Re: Defining specific vars in conf for a shared script
>
>
> Chris Faust wrote:
> > That helps Tom, I wasn't even sure if it was "PerlSetVar" that I needed
to
> > do.
> >
> > Beyond that, how do I get that from within script? If I'm going to use
> > something in my script to read in the conf file then how do I know which
> > config file I want?
> >
> > Using your example is there some
> > "$r->get_vhost_settings{'HTML_TEMPLATE_ROOT'}" to get that value?
>
> for PerlSetVar it's
>
> use Apache::RequestUtil ();
> use APR::Table ();
>
> $r->dir_config->get('HTML_TEMPLATE_ROOT');
>
> $r will be scoped to the current request, so you'll only get those
> PerlSetVar settings that apply to the current vhost or container.
>
> this is pretty standard stuff, so you might want to check out some of the
> docs or books listed at perl.apache.org for more on directive scoping,
> PerlSetVar and the like.
>
> HTH
>
> --Geoff
>
--
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html
Re: Defining specific vars in conf for a shared script
Posted by Chris Faust <cf...@doyougot.com>.
Thanks Geoffrey,
That is exactly what I wanted to know.
-Chris
----- Original Message -----
From: "Geoffrey Young" <ge...@modperlcookbook.org>
To: "Chris Faust" <cf...@doyougot.com>
Cc: "Tom Schindl" <to...@gmx.at>; <mo...@perl.apache.org>
Sent: Sunday, April 18, 2004 1:23 PM
Subject: Re: Defining specific vars in conf for a shared script
>
>
> Chris Faust wrote:
> > That helps Tom, I wasn't even sure if it was "PerlSetVar" that I needed
to
> > do.
> >
> > Beyond that, how do I get that from within script? If I'm going to use
> > something in my script to read in the conf file then how do I know which
> > config file I want?
> >
> > Using your example is there some
> > "$r->get_vhost_settings{'HTML_TEMPLATE_ROOT'}" to get that value?
>
> for PerlSetVar it's
>
> use Apache::RequestUtil ();
> use APR::Table ();
>
> $r->dir_config->get('HTML_TEMPLATE_ROOT');
>
> $r will be scoped to the current request, so you'll only get those
> PerlSetVar settings that apply to the current vhost or container.
>
> this is pretty standard stuff, so you might want to check out some of the
> docs or books listed at perl.apache.org for more on directive scoping,
> PerlSetVar and the like.
>
> HTH
>
> --Geoff
>
--
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html
Re: Defining specific vars in conf for a shared script
Posted by Geoffrey Young <ge...@modperlcookbook.org>.
Chris Faust wrote:
> That helps Tom, I wasn't even sure if it was "PerlSetVar" that I needed to
> do.
>
> Beyond that, how do I get that from within script? If I'm going to use
> something in my script to read in the conf file then how do I know which
> config file I want?
>
> Using your example is there some
> "$r->get_vhost_settings{'HTML_TEMPLATE_ROOT'}" to get that value?
for PerlSetVar it's
use Apache::RequestUtil ();
use APR::Table ();
$r->dir_config->get('HTML_TEMPLATE_ROOT');
$r will be scoped to the current request, so you'll only get those
PerlSetVar settings that apply to the current vhost or container.
this is pretty standard stuff, so you might want to check out some of the
docs or books listed at perl.apache.org for more on directive scoping,
PerlSetVar and the like.
HTH
--Geoff
--
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html
Re: Defining specific vars in conf for a shared script
Posted by Chris Faust <cf...@doyougot.com>.
That helps Tom, I wasn't even sure if it was "PerlSetVar" that I needed to
do.
Beyond that, how do I get that from within script? If I'm going to use
something in my script to read in the conf file then how do I know which
config file I want?
Using your example is there some
"$r->get_vhost_settings{'HTML_TEMPLATE_ROOT'}" to get that value?
Thanks
-Chris
----- Original Message -----
From: "Tom Schindl" <to...@gmx.at>
To: <mo...@perl.apache.org>
Sent: Sunday, April 18, 2004 10:36 AM
Subject: Re: Defining specific vars in conf for a shared script
> Why are you not using config files and only set the path to this file
> like this.
>
> <VirtualHost *:80>
> PerlSetVar my_cnf /etc/vhostconfs/80.cnf
> <VirtualHost>
>
> <VirtualHost *:81>
> PerlSetVar my_cnf /etc/vhostconfs/81.cnf
> <VirtualHost>
>
> 80.cnf
> ---------8<---------
> HTML_TEMPLATE_ROOT = "/websites/80/templates"
> --------->8---------
>
> You could read the config-file when your application starts-up and then
> retrieve the values very easily using something like e.g.
> http://search.cpan.org/~wadg/Config-IniFiles-2.38/
>
> Tom
>
> Chris Faust wrote:
> > Hello,
> >
> > I'm having a hard time figuring out a approach to what I thought would
> > be a simple thing, but after reading a bit through the docs I'm more
> > confused now and was hoping to get some advise.
> >
> > What I want to do is have a single mp2 script service multiple virtual
> > hosts, in order to do this I'd need to set some specific settings
> > related to that virtual host which I can then retrieve from the mp2
> > script - being able to set something like a hash in the conf for each
> > virtualhost and then have access to all those keys and values would be
> > perfect.
> >
> > For a example, I use HTML template, in my script I define the location
> > of all my templates:
> >
> > $ENV{'HTML_TEMPLATE_ROOT'} = "/websites/domain1/templates";
> >
> > I want that to become something like
> >
> > $ENV{'HTML_TEMPLATE_ROOT'} =
> > $settings{'this_path_was_defined_in_the_conf_for_this_vh'};
> >
> > So now that line is good for all the virtualhosts.
> >
> > Thanks
> > -Chris
> >
>
>
> --
> Report problems: http://perl.apache.org/bugs/
> Mail list info: http://perl.apache.org/maillist/modperl.html
> List etiquette: http://perl.apache.org/maillist/email-etiquette.html
>
--
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html
Re: Defining specific vars in conf for a shared script
Posted by Tom Schindl <to...@gmx.at>.
Why are you not using config files and only set the path to this file
like this.
<VirtualHost *:80>
PerlSetVar my_cnf /etc/vhostconfs/80.cnf
<VirtualHost>
<VirtualHost *:81>
PerlSetVar my_cnf /etc/vhostconfs/81.cnf
<VirtualHost>
80.cnf
---------8<---------
HTML_TEMPLATE_ROOT = "/websites/80/templates"
--------->8---------
You could read the config-file when your application starts-up and then
retrieve the values very easily using something like e.g.
http://search.cpan.org/~wadg/Config-IniFiles-2.38/
Tom
Chris Faust wrote:
> Hello,
>
> I'm having a hard time figuring out a approach to what I thought would
> be a simple thing, but after reading a bit through the docs I'm more
> confused now and was hoping to get some advise.
>
> What I want to do is have a single mp2 script service multiple virtual
> hosts, in order to do this I'd need to set some specific settings
> related to that virtual host which I can then retrieve from the mp2
> script - being able to set something like a hash in the conf for each
> virtualhost and then have access to all those keys and values would be
> perfect.
>
> For a example, I use HTML template, in my script I define the location
> of all my templates:
>
> $ENV{'HTML_TEMPLATE_ROOT'} = "/websites/domain1/templates";
>
> I want that to become something like
>
> $ENV{'HTML_TEMPLATE_ROOT'} =
> $settings{'this_path_was_defined_in_the_conf_for_this_vh'};
>
> So now that line is good for all the virtualhosts.
>
> Thanks
> -Chris
>
--
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html
Re: Defining specific vars in conf for a shared script
Posted by Tom Schindl <to...@bestsolution.at>.
Why are you not using config files and only set the path to this file
like this.
<VirtualHost *:80>
PerlSetVar my_cnf /etc/vhostconfs/80.cnf
<VirtualHost>
<VirtualHost *:81>
PerlSetVar my_cnf /etc/vhostconfs/81.cnf
<VirtualHost>
80.cnf
---------8<---------
HTML_TEMPLATE_ROOT = "/websites/80/templates"
--------->8---------
You could read the config-file when your application starts-up and then
retrieve the values very easily using something like e.g.
http://search.cpan.org/~wadg/Config-IniFiles-2.38/
Tom
Chris Faust wrote:
> Hello,
>
> I'm having a hard time figuring out a approach to what I thought would
> be a simple thing, but after reading a bit through the docs I'm more
> confused now and was hoping to get some advise.
>
> What I want to do is have a single mp2 script service multiple virtual
> hosts, in order to do this I'd need to set some specific settings
> related to that virtual host which I can then retrieve from the mp2
> script - being able to set something like a hash in the conf for each
> virtualhost and then have access to all those keys and values would be
> perfect.
>
> For a example, I use HTML template, in my script I define the location
> of all my templates:
>
> $ENV{'HTML_TEMPLATE_ROOT'} = "/websites/domain1/templates";
>
> I want that to become something like
>
> $ENV{'HTML_TEMPLATE_ROOT'} =
> $settings{'this_path_was_defined_in_the_conf_for_this_vh'};
>
> So now that line is good for all the virtualhosts.
>
> Thanks
> -Chris
>
--
b e s t s o l u t i o n . a t EDV Systemhaus GmbH
------------------------------------------------------------------------
tom schindl leiter softwareentwicklung mobile ++43 664 3145958
------------------------------------------------------------------------
eduard-bodem-gasse 8/3 A-6020 innsbruck fax ++43 512 935833
http://www.bestsolution.at phone ++43 512 935834
--
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html