NotifyByEmail.pm 3.35 KB
Newer Older
Leo Gordon's avatar
Leo Gordon committed
1 2 3 4
=pod 

=head1 NAME

5
    Bio::EnsEMBL::Hive::RunnableDB::NotifyByEmail
Leo Gordon's avatar
Leo Gordon committed
6

Leo Gordon's avatar
Leo Gordon committed
7 8
=head1 SYNOPSIS

9 10 11
    This is a RunnableDB module that implements Bio::EnsEMBL::Hive::Process interface
    and is ran by Workers during the execution of eHive pipelines.
    It is not generally supposed to be instantiated and used outside of this framework.
Leo Gordon's avatar
Leo Gordon committed
12

13
    Please refer to Bio::EnsEMBL::Hive::Process documentation to understand the basics of the RunnableDB interface.
Leo Gordon's avatar
Leo Gordon committed
14

15
    Please refer to Bio::EnsEMBL::Hive::PipeConfig::* pipeline configuration files to understand how to configure pipelines.
Leo Gordon's avatar
Leo Gordon committed
16

Leo Gordon's avatar
Leo Gordon committed
17 18
=head1 DESCRIPTION

19 20 21 22 23 24 25 26 27
    This RunnableDB module will send you a short notification email message per each job.
    You can either dataflow into it, or simply create standalone jobs.

    Note: this module depends heavily on the implementation of your compute farm.
    Sendmail may be unsupported, or supported differently.
    Please make sure it works as intended before using this module in complex pipelines.

=head1 LICENSE

28
    Copyright [1999-2014] Wellcome Trust Sanger Institute and the EMBL-European Bioinformatics Institute
Leo Gordon's avatar
Leo Gordon committed
29

30 31 32 33 34 35 36 37
    Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

         http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software distributed under the License
    is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and limitations under the License.
Leo Gordon's avatar
Leo Gordon committed
38

Leo Gordon's avatar
Leo Gordon committed
39 40
=head1 CONTACT

41
    Please contact ehive-users@ebi.ac.uk mailing list with questions/suggestions.
Leo Gordon's avatar
Leo Gordon committed
42 43 44

=cut

45

Leo Gordon's avatar
Leo Gordon committed
46 47 48 49
package Bio::EnsEMBL::Hive::RunnableDB::NotifyByEmail;

use strict;

50
use base ('Bio::EnsEMBL::Hive::Process');
Leo Gordon's avatar
Leo Gordon committed
51

52 53 54 55 56 57 58
sub param_defaults {
    return {
            'subject' => 'An automatic message from your pipeline',
    };
}


Leo Gordon's avatar
Leo Gordon committed
59
=head2 fetch_input
Leo Gordon's avatar
Leo Gordon committed
60

Leo Gordon's avatar
Leo Gordon committed
61 62 63 64 65 66
    Description : Implements fetch_input() interface method of Bio::EnsEMBL::Hive::Process that is used to read in parameters and load data.
                  Here we have nothing to do.

=cut

sub fetch_input {
Leo Gordon's avatar
Leo Gordon committed
67 68
}

Leo Gordon's avatar
Leo Gordon committed
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
=head2 run

    Description : Implements run() interface method of Bio::EnsEMBL::Hive::Process that is used to perform the main bulk of the job (minus input and output).
                  Here the actual sending of the email message happens in run() though one may argue it is technically 'output'.

    param('email'):   The email address to send the message to.

    param('subject'): The (optional) 'Subject:' line.

    param('text'):    Text of the email message. It will undergo parameter substitution.

    param('*'):       Any other parameters can be freely used for parameter substitution.

=cut

Leo Gordon's avatar
Leo Gordon committed
84 85 86
sub run {
    my $self = shift;

87 88 89
    my $email   = $self->param_required('email');
    my $subject = $self->param_required('subject');
    my $text    = $self->param_required('text');
Leo Gordon's avatar
Leo Gordon committed
90

Leo Gordon's avatar
bug fix  
Leo Gordon committed
91
    open(SENDMAIL, "|sendmail $email");
Leo Gordon's avatar
Leo Gordon committed
92 93 94 95 96 97
    print SENDMAIL "Subject: $subject\n";
    print SENDMAIL "\n";
    print SENDMAIL "$text\n";
    close SENDMAIL;
}

Leo Gordon's avatar
Leo Gordon committed
98
=head2 write_output
Leo Gordon's avatar
Leo Gordon committed
99

Leo Gordon's avatar
Leo Gordon committed
100 101 102 103 104 105
    Description : Implements write_output() interface method of Bio::EnsEMBL::Hive::Process that is used to deal with job's output after the execution.
                  Here we have nothing to do.

=cut

sub write_output {
Leo Gordon's avatar
Leo Gordon committed
106 107 108
}

1;