RE: Best approach to store Application Configuration

2011-07-11 Thread James B. Muir
This page describes pretty well how to set up custom configuration directives; 
perhaps helpful?

http://perl.apache.org/docs/2.0/user/config/custom.html

-James

From: Jerry Pereira [mailto:online.je...@gmail.com]
Sent: Monday, July 11, 2011 5:08 PM
To: modperl@perl.apache.org
Subject: Best approach to store Application Configuration

Hi All,

I am new to mod_perl (a java developer). I would like to know the best approach 
to store and retrieve Applicaiton configurations that is accessible to all 
packages in my mod_perl application.

My application configuration includes - Database details, Template mapping, 
LDAP configuration details etc. I would like my to load all these 
configuratoins when my application starts and then on, i should be able to 
access these configuration from anywhere.

For Example:
my $dbDetails = ConfigUtil-getDBDetails(); //returns reference to hash
my dbUser = dbDetails-user;

I belive PerlSetVar only allows strings variables. I would like to get some 
suggestions on how configuration management in mod_perl applications.

Thanks,
Jerry

IMPORTANT NOTICE REGARDING THIS ELECTRONIC MESSAGE:

This message is intended for the use of the person to whom it is addressed and 
may contain information that is privileged, confidential, and protected from 
disclosure under applicable law. If you are not the intended recipient, your 
use of this message for any purpose is strictly prohibited. If you have 
received this communication in error, please delete the message and notify the 
sender so that we may correct our records.


RE: Best approach to store Application Configuration

2011-07-11 Thread Szekeres, Edward
Database

Flatfile on disk (look up Storable module on how to save/load  binary 
representation of PERL structures), works well if you want to have an instant 
structure, but flatfiles need location on the server.

I use both regularly

From: Jerry Pereira [mailto:online.je...@gmail.com]
Sent: Monday, July 11, 2011 5:08 PM
To: modperl@perl.apache.org
Subject: Best approach to store Application Configuration

Hi All,

I am new to mod_perl (a java developer). I would like to know the best approach 
to store and retrieve Applicaiton configurations that is accessible to all 
packages in my mod_perl application.

My application configuration includes - Database details, Template mapping, 
LDAP configuration details etc. I would like my to load all these 
configuratoins when my application starts and then on, i should be able to 
access these configuration from anywhere.

For Example:
my $dbDetails = ConfigUtil-getDBDetails(); //returns reference to hash
my dbUser = dbDetails-user;

I belive PerlSetVar only allows strings variables. I would like to get some 
suggestions on how configuration management in mod_perl applications.

Thanks,
Jerry


Re: Best approach to store Application Configuration

2011-07-11 Thread Michael Peters

On 07/11/2011 05:16 PM, James B. Muir wrote:

This page describes pretty well how to set up custom configuration
directives; perhaps helpful?

http://perl.apache.org/docs/2.0/user/config/custom.html


I would almost always avoid this kind of configuration and go with an 
external configuration file. Every project of any decent size will have 
some scripts or processes that don't run under mod_perl and thus can't 
use this apache-only configuration.


As for configuration in Perl if I were starting a new project, I'd 
probably go with something like Config::Any and then pick a backend 
format. But in practice it probably doesn't matter a whole lot which 
config module you use as long as it's not tied to Apache. But if you 
like the apache-style format you can use Config::ApacheFormat which 
works well.


--
Michael Peters
Plus Three, LP


Re: Best approach to store Application Configuration

2011-07-11 Thread McCarrell, Jeff
Hi Jerry.

I went through a couple of different approaches before settling on using YAML 
files to describe configuration.
There are several nice properties of YAML IMO, not least of which is arbitrary 
nesting so the config can closely match the software being configured.
Here is a sanitized example of my production config:

# -*- mode: perl -*-
# configuration file for XXX
config: { version: 1 }

# XYZ configuration
#  across the entire XXX tier
xyz: {
  # enable / disable all ...
  feature_X_enabled: true,

  # name of cookie(s) to emit: [xx, yy, zz]
  emit_cookies: [ xx ]

  # substructure configuration
  sub_structures: {
disabled: {
  foo: [],
  bar: [],
  baz: [],
}
  }
}

There are several YAML readers available; I preferred YAML::XS because of its 
speed and correctness.
My apps need to run a long time, so they poll the configuration file every n 
seconds, and reload it if needed.
Overall, I was pretty happy with this approach, and so were the operations 
folks who have to configure the settings in production.

HTH,
-- jeff

From: Jerry Pereira online.je...@gmail.commailto:online.je...@gmail.com
Date: Mon, 11 Jul 2011 16:07:58 -0500
To: modperl@perl.apache.orgmailto:modperl@perl.apache.org 
modperl@perl.apache.orgmailto:modperl@perl.apache.org
Subject: Best approach to store Application Configuration

Hi All,

I am new to mod_perl (a java developer). I would like to know the best approach 
to store and retrieve Applicaiton configurations that is accessible to all 
packages in my mod_perl application.

My application configuration includes - Database details, Template mapping, 
LDAP configuration details etc. I would like my to load all these 
configuratoins when my application starts and then on, i should be able to 
access these configuration from anywhere.

For Example:
my $dbDetails = ConfigUtil-getDBDetails(); //returns reference to hash
my dbUser = dbDetails-user;

I belive PerlSetVar only allows strings variables. I would like to get some 
suggestions on how configuration management in mod_perl applications.

Thanks,
Jerry


Re: Best approach to store Application Configuration

2011-07-11 Thread Fred Moyer
On Mon, Jul 11, 2011 at 2:23 PM, Michael Peters mpet...@plusthree.com wrote:
 On 07/11/2011 05:16 PM, James B. Muir wrote:

 This page describes pretty well how to set up custom configuration
 directives; perhaps helpful?

 http://perl.apache.org/docs/2.0/user/config/custom.html

 I would almost always avoid this kind of configuration and go with an
 external configuration file. Every project of any decent size will have some
 scripts or processes that don't run under mod_perl and thus can't use this
 apache-only configuration.

This kind of configuration has the advantage of avoiding the overhead
associated with PerlSetVar if I recall correctly.  The downside is
that the custom config directives can be a bit tricky to setup
correctly.

 As for configuration in Perl if I were starting a new project, I'd probably
 go with something like Config::Any and then pick a backend format.

+1


Re: Best approach to store Application Configuration

2011-07-11 Thread Jerry Pereira
please correct me if I am wrong, I should be using tool like
YAML/Config::General for application configuration storage and reteieval,
and load them on startup using startup.pl script? That would mean i will
have to store the name of configuration file some where (probabaly in
mod_perl configuration block in httpd.conf).

On Mon, Jul 11, 2011 at 2:26 PM, McCarrell, Jeff jmcca...@akamai.comwrote:

  Hi Jerry.

 I went through a couple of different approaches before settling on using
 YAML files to describe configuration.
 There are several nice properties of YAML IMO, not least of which is
 arbitrary nesting so the config can closely match the software being
 configured.
 Here is a sanitized example of my production config:

  # -*- mode: perl -*-
 # configuration file for XXX
 config: { version: 1 }

 # XYZ configuration
 #  across the entire XXX tier
 xyz: {
   # enable / disable all ...
   feature_X_enabled: true,

   # name of cookie(s) to emit: [xx, yy, zz]
   emit_cookies: [ xx ]

   # substructure configuration
   sub_structures: {
 disabled: {
   foo: [],
   bar: [],
   baz: [],
 }
   }
 }

 There are several YAML readers available; I preferred YAML::XS because of
 its speed and correctness.
 My apps need to run a long time, so they poll the configuration file every
 n seconds, and reload it if needed.
 Overall, I was pretty happy with this approach, and so were the operations
 folks who have to configure the settings in production.

 HTH,
 -- jeff

 From: Jerry Pereira online.je...@gmail.com
 Date: Mon, 11 Jul 2011 16:07:58 -0500
 To: modperl@perl.apache.org modperl@perl.apache.org

 Subject: Best approach to store Application Configuration

 Hi All,

 I am new to mod_perl (a java developer). I would like to know the best
 approach to store and retrieve Applicaiton configurations that is accessible
 to all packages in my mod_perl application.

 My application configuration includes - Database details, Template mapping,
 LDAP configuration details etc. I would like my to load all these
 configuratoins when my application starts and then on, i should be able to
 access these configuration from anywhere.

 For Example:
 my $dbDetails = ConfigUtil-getDBDetails(); //returns reference to hash
 my dbUser = dbDetails-user;

 I belive PerlSetVar only allows strings variables. I would like to get some
 suggestions on how configuration management in mod_perl applications.

 Thanks,
 Jerry




-- 
Your clothes may be the latest in style but you aint completely dressed
until you wear a smile!
Keep smiling : )


RE: Best approach to store Application Configuration

2011-07-11 Thread James B. Muir
The PerlSetVar overhead occurs on every request, whereas the overhead 
associated with using the custom configuration occurs once when Apache is 
started.
-James


-Original Message-
From: Fred Moyer [mailto:f...@redhotpenguin.com]
Sent: Monday, July 11, 2011 5:35 PM
To: Michael Peters
Cc: James B. Muir; Jerry Pereira; modperl@perl.apache.org
Subject: Re: Best approach to store Application Configuration

On Mon, Jul 11, 2011 at 2:23 PM, Michael Peters mpet...@plusthree.com wrote:
 On 07/11/2011 05:16 PM, James B. Muir wrote:

 This page describes pretty well how to set up custom configuration
 directives; perhaps helpful?

 http://perl.apache.org/docs/2.0/user/config/custom.html

 I would almost always avoid this kind of configuration and go with an
 external configuration file. Every project of any decent size will have some
 scripts or processes that don't run under mod_perl and thus can't use this
 apache-only configuration.

This kind of configuration has the advantage of avoiding the overhead
associated with PerlSetVar if I recall correctly.  The downside is
that the custom config directives can be a bit tricky to setup
correctly.

 As for configuration in Perl if I were starting a new project, I'd probably
 go with something like Config::Any and then pick a backend format.

+1

IMPORTANT NOTICE REGARDING THIS ELECTRONIC MESSAGE:

This message is intended for the use of the person to whom it is addressed and 
may contain information that is privileged, confidential, and protected from 
disclosure under applicable law.  If you are not the intended recipient, your 
use of this message for any purpose is strictly prohibited.  If you have 
received this communication in error, please delete the message and notify the 
sender so that we may correct our records.


Re: Best approach to store Application Configuration

2011-07-11 Thread McCarrell, Jeff
Naming the path to the config file in an httpd conf will certainly work.
In my case, the path the config file is hard coded in the method that reads the 
config as it is not something that changes.

Here is on of my httpd conf file (a separate file loaded in the http 
configuration directory so your install process doesn't have to change the 
actual httpd.conf):
PerlModuleYour::App
PerlPostConfigHandler Your::App::httpd_start

Location /foo/app
SetHandler modperl
PerlResponseHandler   +Your::App

# Apache::DBI needs GlobalRequest
PerlOptions +GlobalRequest
/Location

The httpd_start method gets called at apache startup time, and reads the config 
in once.

Also, one other possible advantage to YAML is that YAML is not perl, so if you 
have a mixed language env,
it is easy to share/move/port your config to the language of your choice.
YAML has pretty good support across the common languages you will find in the 
LAMP world.

BTW, if you haven't already done so, I recommend becoming familiar with the 
handlers and their life cycles:
http://perl.apache.org/docs/2.0/user/handlers/server.html
http://perl.apache.org/docs/2.0/user/handlers/http.html#HTTP_Request_Cycle_Phases

Have fun,

-- jeff

From: Jerry Pereira online.je...@gmail.commailto:online.je...@gmail.com
Date: Mon, 11 Jul 2011 16:41:13 -0500
To: Jeff McCarrell jmcca...@akamai.commailto:jmcca...@akamai.com
Cc: modperl@perl.apache.orgmailto:modperl@perl.apache.org 
modperl@perl.apache.orgmailto:modperl@perl.apache.org
Subject: Re: Best approach to store Application Configuration

please correct me if I am wrong, I should be using tool like 
YAML/Config::General for application configuration storage and reteieval, and 
load them on startup using startup.plhttp://startup.pl script? That would 
mean i will have to store the name of configuration file some where (probabaly 
in mod_perl configuration block in httpd.conf).




Re: Best approach to store Application Configuration

2011-07-11 Thread Michael Peters

On 07/11/2011 05:41 PM, Jerry Pereira wrote:

please correct me if I am wrong, I should be using tool like
YAML/Config::General for application configuration storage and
reteieval, and load them on startup using startup.pl http://startup.pl
script?


Yes.


That would mean i will have to store the name of configuration
file some where (probabaly in mod_perl configuration block in httpd.conf).


Again, if you think about just using a mod_perl specific way of doing 
this you'll leave all of your non-mod_perl stuff out in the cold and any 
project of significant size is going to have some non-mod_perl processes 
involved somewhere.


I prefer to use environment variables if you need to specify the 
location of a config file. These are available no matter where you're 
running (in mod_perl you'll want to use a PerlPassEnv directive so the 
mod_perl side sees it).


--
Michael Peters
Plus Three, LP


Re: Best approach to store Application Configuration

2011-07-11 Thread Keywan Ghadami

Hi Jerry,
I use JSON:XS in my framework, but
before writing a hole framework from the scratch, think about using
catalyst.
 regards keywan




Am 11.07.2011 23:07, schrieb Jerry Pereira:

Hi All,

I am new to mod_perl (a java developer). I would like to know the best
approach to store and retrieve Applicaiton configurations that is accessible
to all packages in my mod_perl application.

My application configuration includes - Database details, Template mapping,
LDAP configuration details etc. I would like my to load all these
configuratoins when my application starts and then on, i should be able to
access these configuration from anywhere.

For Example:
my $dbDetails = ConfigUtil-getDBDetails(); //returns reference to hash
my dbUser = dbDetails-user;

I belive PerlSetVar only allows strings variables. I would like to get some
suggestions on how configuration management in mod_perl applications.

Thanks,
Jerry




--
Mit freundlichen Grüßen
Keywan Ghadami
Telefon +49 (0)75 31 / 81 39 7 95
Fax +49 (0)75 31 / 81 39 7 89
Anschrift
ibson
Fritz-Arnold-Str. 23
D-78467 Konstanz