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 <[email protected]<mailto:[email protected]>>
Date: Mon, 11 Jul 2011 16:07:58 -0500
To: "[email protected]<mailto:[email protected]>"
<[email protected]<mailto:[email protected]>>
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