MMM::Batch - MMM::Batch documentation


mmm documentation Contained in the mmm distribution.

Index


Code Index:

NAME

Top

MMM::Batch

SYNOPSIS

Top

    use MMM::Batch;
    my $mmm = MMM::Batch->new() or die "Cannot find MMM installation";
    $mmm->run();

DESCRIPTION

Top

A daemon for mmm system

SEE ALSO

Top

MMM

AUTHOR

Top

Olivier Thauvin <nanardon@nanardon.zarb.org>

COPYRIGHT AND LICENSE

Top


mmm documentation Contained in the mmm distribution.
package MMM::Batch;

use strict;
use warnings;

use base qw(MMM);
use base qw(MMM::Report::Mail);

sub new {
    my ($class, @args) = @_;
    my $mmm = $class->SUPER::new(@args) or return;

    if (!$mmm->{nofork}) {
        Sys::Syslog::openlog('mmm', 'pid', $mmm->configval('default', 'syslog_facilities', 'daemon'));
        $mmm->{use_syslog} = 1;
    }

    $mmm
}

sub run {
    my ( $self ) = @_;

    $self->load();

    my @started_tasks = ();
    foreach my $q ($self->get_tasks_by_name($self->list_tasks)) {
        $q->is_disable() and next;
        $q->frequency or next;
        $q->next_run_time <= scalar(time) or next;
        push(@started_tasks, $q->name);
        $self->_run_fork($q);
    }

    if (@started_tasks) {
        $self->log('DEBUG', 'Started tasks: %s', join(', ', @started_tasks));
    } else {
        $self->log('INFO', 'No task need to be run currently');
    }

    $self->_reap_message();
    $self->_reap_child();

    if ( $self->configval( 'default', 'publish_list' ) ) {
        $self->write_list();
    }
}

1;

__END__