NotifyByEmail.pm 3.5 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-2015] Wellcome Trust Sanger Institute and the EMBL-European Bioinformatics Institute
Matthieu Muffato's avatar
Matthieu Muffato committed
29
    Copyright [2016-2018] EMBL-European Bioinformatics Institute
Leo Gordon's avatar
Leo Gordon committed
30

31 32 33 34 35 36 37 38
    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
39

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

42
    Please subscribe to the Hive mailing list:  http://listserver.ebi.ac.uk/mailman/listinfo/ehive-users  to discuss Hive-related questions or to be notified of our updates
Leo Gordon's avatar
Leo Gordon committed
43 44 45

=cut

46

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

use strict;

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

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


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

Leo Gordon's avatar
Leo Gordon committed
62 63 64 65 66 67
    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
68 69
}

Leo Gordon's avatar
Leo Gordon committed
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
=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
85 86 87
sub run {
    my $self = shift;

88 89 90
    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
91

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

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

Leo Gordon's avatar
Leo Gordon committed
101 102 103 104 105 106
    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
107 108 109
}

1;