Clustericious::Config - Configuration files for Clustericious nodes.


version 1.29


In your ~/etc/MyApp.conf file:

 % extends_config 'global';
 % extends_config 'hypnotoad', url => 'http://localhost:9999', app => 'MyApp';

 url : http://localhost:9999
 start_mode : hypnotoad
 hypnotoad :
   - heartbeat_timeout : 500
 arbitrary_key: value

In your ~/etc/globa.conf file:

 somevar : somevalue

In your ~/etc/hypnotoad.conf:

 listen :
   - <%= $url %>
 # home uses ~ to find the calling users'
 # home directory
 pid_file : <%= home %>/<%= $app %>/
 env :
   MOJO_HOME : <%= home %>/<%= $app %>

From a Clustericious::App:

 package MyApp;
 use Mojo::Base qw( Clustericious::App );
 package MyApp::Routes;
 use Clustericious::RouteBuilder;
 get '/' => sub {
   my $c = shift;
   my $config = $c; # $config isa Clustericious::Config
   # returns the value if it is defined, foo otherwise
   my $value1 = $config->arbitrary_key1(default => 'foo');
   # returns the value if it is defined, bar otherwise
   # code reference is only called if the value is NOT
   # defined
   my $value2 = $config->arbitrary_key2(default => sub { 'bar' });

From a script:

 use Clustericious::Config;
 my $c = Clustericious::Config->new("MyApp");
 my $c = Clustericious::Config->new( \%config_data_structure );

 print $c->url;
 print $c->{url};

 print $c->hypnotoad->listen;
 print $c->hypnotoad->{listen};
 my %hash = $c->hypnotoad;
 my @ary  = $c->hypnotoad;

 # Supply a default value for a missing configuration parameter :
 $c->url(default => "http://localhost:9999");
 print $c->this_param_is_missing(default => "something_else");


Clustericious::Config reads configuration files which are Mojo::Template's of JSON or YAML files. There should generally be an entry for 'url', which may be used by either a client or a server depending on how this node in the cluster is being used.

After rendering the template and parsing the JSON, the resulting object may be called using method calls or treated as hashes.

Config files are looked for in the following places (in order, where "MyApp" is the name of the app) :


The helper "extends_config" may be used to read default settings from another config file. The first argument to extends_config is the basename of the config file. Additional named arguments may be passed to that config file and used as variables within that file. After reading another file, the hashes are merged (i.e. with Hash::Merge); so values anywhere inside the data structure may be overridden.

YAML config files must begin with "---", otherwise they are interpreted as JSON.

This module provides a number of helpers which can be used to get system details (such as the home directory of the calling user or to prompt for passwords). See Clustericious::Config::Helpers for details.



Create a new Clustericious::Config object. See the SYNOPSIS for possible invocations.


Some filesystems do not support filenames with a colon (:) character in them, so for applications with a double colon in them (for example Clustericious::HelloWorld), a single dash character will be substituted for the name (for example Clustericious-HelloWorld.conf).

Clustericious::Config uses AUTOLOAD to perform its magic, so some configuration keys that are reserved by Perl cannot be used. Notably new, can, isa, etc.


Mojo::Template, Hash::Merge, Clustericious, Clustericious::Client, Clustericious::Config::Helpers


Original author: Brian Duggan

Current maintainer: Graham Ollis <>


Curt Tilmes

Yanick Champoux


This software is copyright (c) 2013 by NASA GSFC.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.