XAS::Lib::Modules::Environment - The base environment for the XAS environment
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);
This module describes the base environment for XAS. This module is implemented as a singleton and will be auto-loaded when invoked.
This method will initialize the base module. It parses the current environment using the following variables:
The root of the directory structure. On Unix like boxes this will be / and Windows this will be C:\XAS.
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.
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.
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.
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.
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.
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
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.
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.
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.
The domain of the system: If not provided, then Net::Domain::hostdomain() will be used.
The server where a STOMP enabled message queue server is located. Default is "localhost".
The port that server is listening on. Default is "61613".
This sets the STOMP protocol level. The default is v1.0.
The server where a SMTP based mail server resides. Default is "localhost".
The port it is listening on. Default is "25".
The mailer to use for sending email. On Unix like boxes this will be "sendmail" on Windows this will be "smtp".
The regex to use when searching for message files. Defaults to /.*\.msg/i.
The syslog facility class to use. Defaults to 'local6'. It uses the syslog conventions.
The log type. This can be "console", "file", "json" or "syslog". Defaults to "console"
The default error message type. Defaults to 'xas'.
The error message priority type. Defaults to "low".
The error message facility type. Defaults to "systems".
This method sets or returns wither to send alerts.
This method sets or returns the status of debug.
This method returns the name of the script.
This method returns the complete commandline.
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'.
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');
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.
$logfile = $xas->log_file; $xas->log_file("/some/path/mylogfile.log");
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.
$pidfile = $xas->pid_file; $xas->pid_file("/some/path/myfile.pid");
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.
$inifile = $xas->cfg_file; $xas->cfg_file("/some/path/myfile.cfg");
This method will return the name of the message queue server. Or you can store a different name for the server.
$mqserver = $xas->mqserver; $xas->mqserver('mq.example.com');
This method will return the port for the message queue server, or you store a different port number for that server.
This method will returns the STOMP protocol level. or you store a different level. It can use 1.0, 1.1 or 1.2.
$mqlevel = $xas->mqlevel; $xas->mqlevel('1.0');
This method will return the name of the mail server. Or you can store a different name for the server.
$mxserver = $xas->mxserver; $xas->mxserver('mail.example.com');
This method will return the port for the mail server, or you store a different port number for that server.
$mxport = $xas->mxport; $xas->mxport('25');
This method will return the mailer to use for sending email, or you can change the mailer used.
$mxmailer = $xas->mxmailer; $xas->mxmailer('smtp');
This accessor returns the currently defined path for this program.
This accessor returns the root directory of the XAS environment.
This accessor returns the bin directory of the XAS environment. The bin directory is used to place executable commands.
This accessor returns the sbin directory of the XAS environment. The sbin directory is used to place system level commands.
This accessor returns the log directory of the XAS environment.
This accessor returns the run directory of the XAS environment. The run directory is used to place pid files and other such files.
This accessor returns the etc directory of the XAS environment. Application configuration files should go into this directory.
This accessor returns the lib directory of the XAS environment. This directory is used to store supporting file for the environment.
This accessor returns the spool directory of the XAS environment. This directory is used to store spool files generated within the environment.
This accessor returns the tmp directory of the XAS environment. This directory is used to store temporary files.
This accessor returns the var directory of the XAS environment.
This accessor returns the local hostname.
This access returns the domain name of the local host.
This accessor returns the effective username of the current process.
The accessor to return the regex for messages files.
Kevin L. Esteb, <kevin@kesteb.us>
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.
To install XAS, copy and paste the appropriate command in to your terminal.
cpanm
cpanm XAS
CPAN shell
perl -MCPAN -e shell install XAS
For more information on module installation, please visit the detailed CPAN module installation guide.