Config

The Config library finds the etc directory and reads the Assure1.conf file in JSON format.

Synopsis

our $Config = new Assure1::Config();

# Find the path to an application
my $RunScript = $Config->{BaseDir} . '/bin/RunScript';

# Save Event DB shard ID
$Config->{DBShards}->{Event} = 3;

# Use a non-standard config file
our $Config = Assure1::Config->new({ 'configPath' => '/path/to/Assure1-custom.conf' });

Setting the configPath option causes all future Assure1::Config instantiations to use that value as the default ConfigPath for the life of the process.

For example:

# will read in BASEDIR/etc/Assure1.conf
our $Config = Assure1::Config->new();

# will read in /path/to/Assure1-custom.conf
our $Config = Assure1::Config->new({ 'configPath' => '/path/to/Assure1-custom.conf' });

# will read in /path/to/Assure1-custom.conf because of custom configPath set for $Config above
our $Config = Assure1::Config->new();

# will read in /path/to/Assure1-another-custom.conf
our $Config = Assure1::Config->new({ 'configPath' => '/path/to/Assure1-another-custom.conf' });

Note:

Use \$BASEDIR or \$Config->{BaseDir} for file paths instead of hard-coding /opt/assure1, so your script works with your Unified Assurance installation path. The only exception is the script interpreter line at the very beginning of the file, such as:

#!/opt/assure1/bin/RunScript