The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

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->pid_file;
  $logfile = $self->env->log_file;

  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 / 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_LOCKS

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

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 %XAS_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.

XAS_LOG_FACILITY

The syslog facility class to use. Defaults to 'local6'. It uses the syslog conventions.

XAS_LOG_TYPE

The log type. This can be "console", "file", "json" or "syslog". Defaults to "console"

XAS_ERR_THROWS

The default error message type. Defaults to 'xas'.

XAS_ERR_PRIORITY

The error message priority type. Defaults to "low".

XAS_ERR_FACILITY

The error message facility type. Defaults to "systems".

alerts

This method sets or returns wither to send alerts.

xdebug

This method sets or returns the status of debug.

script

This method returns the name of the script.

commandline

This method returns the complete commandline.

log_type

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 "console", "file", "json" and "syslog'.

log_facility

This method will return the log facility class to use when writting to syslog or json.

Example

    $facility = $xas->log_facility;
    $xas->log_facility('local6');

log_file

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->log_file;
    $xas->log_file("/some/path/mylogfile.log");

pid_file

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->pid_file;
    $xas->pid_file("/some/path/myfile.pid");

cfg_file

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->cfg_file;
    $xas->cfg_file("/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 is free software; you can redistribute it and/or modify it under the terms of the Artistic License 2.0. For details, see the full text of the license at http://www.perlfoundation.org/artistic_license_2_0.