NAME

XAS::Lib::Modules::Environment - The base environment for the XAS environment

SYNOPSIS

Your program can use this module in the following fashion:

use XAS::Class
  version => '0.01',
  base    => 'XAS::Base',
;

 $pidfile = $self->env->pidfile;
 $logfile = $self->env->logfile;

 printf("The XAS root is %s\n", $self->env->root);

DESCRIPTION

This module describes the base environment for XAS. This module is implemented as a singleton and will be auto-loaded when invoked.

METHODS

new

This method will initialize the base module. It parses the current environment using the following variables:

XAS_ROOT

The root of the directory structure. On Unix like boxes this will be /usr/local and Windows this will be C:\xas.

XAS_LOG

The path for log files. On Unix like boxes this will be /var/log/xas and on Windows this will be %XAS_ROOT%\var\log.

XAS_RUN

The path for pid files. On Unix like boxes this will be /var/run/xas and on Windows this will be %XAS_ROOT%\var\run.

XAS_SPOOL

The base path for spool files. On Unix like boxes this will be /var/spool/xas and on Windows this will be %XRS_ROOT%\var\spool.

XAS_LIB

The path to the lib directory. On Unix like boxes this will be /var/lib/xas and on Windows this will be %XAS_ROOT%\var\lib.

XAS_ETC

The path to the etc directory. On Unix like boxes this will be /usr/local/etc and on Windows this will be %XAS_ROOT%\etc

XAS_BIN

The path to the bin directory. On Unix like boxes this will be /usr/local/bin and on Windows this will be %XAS_ROOT%\bin.

XAS_SBIN

The path to the sbin directory. On Unix like boxes this will be /usr/local/sbin and on Windows this will be %XAS_ROOT%\sbin.

XAS_HOSTNAME

The host name of the system. If not provided, on Unix the "hostname -s" command will be used and on Windows Win32::NodeName() will be called.

XAS_DOMAIN

The domain of the system: If not provided, then Net::Domain::hostdomain() will be used.

XAS_MQSERVER

The server where a STOMP enabled message queue server is located. Default is "localhost".

XAS_MQPORT

The port that server is listening on. Default is "61613".

XAS_MQLEVL

This sets the STOMP protocol level. The default is v1.0.

XAS_MXSERVER

The server where a SMTP based mail server resides. Default is "localhost".

XAS_MXPORT

The port it is listening on. Default is "25".

XAS_MXMAILER

The mailer to use for sending email. On Unix like boxes this will be "sendmail" on Windows this will be "smtp".

XAS_MSGS

The regex to use when searching for message files. Defaults to /.*\.msg/i.

logtype

This method will return the currently defined log type. By default this is "console". i.e. all logging will go to the terminal screen. Valid options are "file", "logstash" and "syslog'.

logfile

This method will return a pre-generated name for a log file. The name will be based on the programs name with a ".log" extension, along with the path to the XAS log file directory. Or you can store your own self generated log file name.

Example

$logfile = $xas->logfile;
$xas->logfile("/some/path/mylogfile.log");

pidfile

This method will return a pre-generated name for a pid file. The name will be based on the programs name with a ".pid" extension, along with the path to the XAS pid file directory. Or you can store your own self generated pid file name.

Example

$pidfile = $xas->pidfile;
$xas->pidfile("/some/path/myfile.pid");

cfgfile

This method will return a pre-generated name for a configuration file. The name will be based on the programs name with a ".ini" extension, along with the path to the XAS configuration file directory. Or you can store your own self generated configuration file name.

Example

$inifile = $xas->cfgfile;
$xas->cfgfile("/some/path/myfile.cfg");

mqserver

This method will return the name of the message queue server. Or you can store a different name for the server.

Example

$mqserver = $xas->mqserver;
$xas->mqserver('mq.example.com');

mqport

This method will return the port for the message queue server, or you store a different port number for that server.

mqlevel

This method will returns the STOMP protocol level. or you store a different level. It can use 1.0, 1.1 or 1.2.

Example

$mqlevel = $xas->mqlevel;
$xas->mqlevel('1.0');

mxserver

This method will return the name of the mail server. Or you can store a different name for the server.

Example

$mxserver = $xas->mxserver;
$xas->mxserver('mail.example.com');

mxport

This method will return the port for the mail server, or you store a different port number for that server.

Example

$mxport = $xas->mxport;
$xas->mxport('25');

mxmailer

This method will return the mailer to use for sending email, or you can change the mailer used.

Example

$mxmailer = $xas->mxmailer;
$xas->mxmailer('smtp');

ACCESSORS

path

This accessor returns the currently defined path for this program.

root

This accessor returns the root directory of the XAS environment.

bin

This accessor returns the bin directory of the XAS environment. The bin directory is used to place executable commands.

sbin

This accessor returns the sbin directory of the XAS environment. The sbin directory is used to place system level commands.

log

This accessor returns the log directory of the XAS environment.

run

This accessor returns the run directory of the XAS environment. The run directory is used to place pid files and other such files.

etc

This accessor returns the etc directory of the XAS environment. Application configuration files should go into this directory.

lib

This accessor returns the lib directory of the XAS environment. This directory is used to store supporting file for the environment.

spool

This accessor returns the spool directory of the XAS environment. This directory is used to store spool files generated within the environment.

tmp

This accessor returns the tmp directory of the XAS environment. This directory is used to store temporary files.

var

This accessor returns the var directory of the XAS environment.

host

This accessor returns the local hostname.

domain

This access returns the domain name of the local host.

username

This accessor returns the effective username of the current process.

msgs

The accessor to return the regex for messages files.

SEE ALSO

XAS

AUTHOR

Kevin L. Esteb, <kevin@kesteb.us>

COPYRIGHT AND LICENSE

Copyright (C) 2014 Kevin L. Esteb

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.

See http://dev.perl.org/licenses/ for more information.