#!/usr/bin/perl
# ============================================================================
#             Copyright (c) 2014 Kevin L. Esteb All Rights Reserved
#
#
# TITLE:       xas-supervisor
#
# FACILITY:    XAS
#
# ABSTRACT:    This procedure will spawn and monitor multiple background
#              processes
#
# ENVIRONMENT: The XAS Middleware Environment
#
# PARAMETERS:
#              --port         the port to listen on
#              --address      the network address to use
#              --cfg-file     which configuration file to use
#              --pid-file     which pid file to use
#              --log-type     toggles the log type
#              --log-facility changes the log facility to use
#              --log-file     name of the log file
#              --help         prints out a helpful help message
#              --manual       prints out the procedures manual
#              --version      prints out the procedures version
#              --debug        toggles debug output
#              --alerts       toggles alert notification
#
# RETURNS:
#              0 - success
#              1 - failure
#
# Version      Author                                              Date
# -------      ----------------------------------------------      -----------
# 0.01         Kevin Esteb                                         04-Dec-2015
#
# ============================================================================
#

use lib "../lib";
use XAS::Apps::Supervisor::Monitor;

main: {

    my $app = XAS::Apps::Supervisor::Monitor->new(
        -throws => 'xas-supervisor',
    );

    exit $app->run();

}

__END__

=head1 NAME

xas-supervisor - supervise and manage background processes

=head1 SYNOPSIS

xas-supervisor [--help] [--debug] [--manual] [--version]

 options:
   --port         the management port to listen on
   --address      the network address to use
   --help         outputs simple help text
   --manual       outputs the procedures manual
   --version      outputs the apps version
   --debug        toogles debugging output
   --alerts       toogles alert notifications
   --cfg-file     which configuration file to use
   --pid-file     which pid file to use
   --log-file     name of the log file 
   --log-type     toggles the log type
   --log-faciilty changes the log facility

=head1 DESCRIPTION

This procedure reads a configuration file and spawns multiple background
processes. It will then try to keep those processes running. External 
management tools can send commands to the supervisor to control those
background processes.

=head1 CONFIGURATION

Please refer to L<XAS::Apps::Supervisor::Monitor|XAS::Apps::Supervisor::Monitor> for 
configuration file information.

=head1 OPTIONS AND ARGUMENTS

=over 4

=item B<--port>

The network port to listen on for management functions.

=item B<--address>

The network address to use.

=item B<-cfg-file>

The configuration file to use.

=item B<--pid-file>

The pid file to use.

=item B<--help>

Displays a simple help message.

=item B<--debug>

Turns on debbuging.

=item B<--alerts>

Togggles alert notification.

=item B<--log-type>

Toggles the log type. Defaults to 'console'. Can be 'console', 'file', 
'json' or 'syslog'.

=item B<--log-facility>

Toggles the log facilty. Defaults to 'local6'. This follows syslog
convention.

=item B<--log-file>

Optional logfile. When specified the log type is set to 'file'.

=item B<--manual>

The complete documentation.

=item B<--version>

Prints out the apps version

=back

=head1 EXIT CODES

 0 - success
 1 - failure

=head1 SEE ALSO

=over 4

=item L<XAS::Apps::Supervisor::Monitor|XAS::Apps::Supervisor::Monitor>

=item L<XAS::Supervisor|XAS::Supervisor>

=item L<XAS|XAS>

=back

=head1 AUTHOR

Kevin L. Esteb, E<lt>kevin@kesteb.usE<gt>

=head1 COPYRIGHT AND LICENSE

Copyright (c) 2012-2015 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.

=cut
