Class: Kuroko2::Notifications

Inherits:
ApplicationMailer show all
Defined in:
app/mailers/kuroko2/notifications.rb

Instance Method Summary collapse

Instance Method Details

#executor_not_assigned(execution, hostname) ⇒ Object



40
41
42
43
44
45
46
# File 'app/mailers/kuroko2/notifications.rb', line 40

def executor_not_assigned(execution, hostname)
  @execution  = execution
  @definition = execution.job_definition
  @instance   = execution.job_instance

  mail(subject: '[CRITICAL] Process is not assigned to any job-executor')
end

#job_failure(job_instance) ⇒ Object



9
10
11
12
13
14
15
16
17
18
# File 'app/mailers/kuroko2/notifications.rb', line 9

def job_failure(job_instance)
  @definition = job_instance.job_definition
  @instance   = job_instance

  attachments.inline['kuroko-logo-horizontal.jpg'] = Kuroko2::Engine.root.join('app/assets/images/kuroko2/kuroko-logo-horizontal.png').read

  mail(subject: "[CRITICAL] Failed to execute '#{@definition.name}' on kuroko",
    to:      @definition.admins.map(&:email),
    cc:      Kuroko2.config.notifiers.mail.mail_to)
end

#notify_long_elapsed_time(job_instance) ⇒ Object



48
49
50
51
52
53
54
55
# File 'app/mailers/kuroko2/notifications.rb', line 48

def notify_long_elapsed_time(job_instance)
  @definition = job_instance.job_definition
  @instance   = job_instance

  mail(subject: "[WARN] The running time is longer than expected '#{@definition.name}' on kuroko",
    to:      @definition.admins.map(&:email),
    cc:      Kuroko2.config.notifiers.mail.mail_to)
end

#process_absence(execution, hostname) ⇒ Object



31
32
33
34
35
36
37
38
# File 'app/mailers/kuroko2/notifications.rb', line 31

def process_absence(execution, hostname)
  @execution  = execution
  @definition = execution.job_definition
  @instance   = execution.job_instance
  @hostname   = hostname

  mail(subject: '[CRITICAL] Process is not running on kuroko')
end

#remind_failure(job_instance) ⇒ Object



20
21
22
23
24
25
26
27
28
29
# File 'app/mailers/kuroko2/notifications.rb', line 20

def remind_failure(job_instance)
  @definition = job_instance.job_definition
  @instance   = job_instance

  attachments.inline['kuroko-logo-horizontal.jpg'] = Kuroko2::Engine.root.join('app/assets/images/kuroko2/kuroko-logo-horizontal.png').read

  mail(subject: "[WARN] '#{@definition.name}' is still in ERROR state",
    to:      @definition.admins.map(&:email),
    cc:      Kuroko2.config.notifiers.mail.mail_to)
end