Trouble sending email using mailjet

51 views
Skip to first unread message

Vell

unread,
Nov 13, 2015, 11:27:16 AM11/13/15
to god.rb
Hello all,

I am new to the mailing list and to God.rb and am having issues getting email to send via mailjet when an event occurs. Unfortunately I am not seeing anything in the log file related to email (or much of anything else) so I am not sure how to debug my issue.

God does successfully restart my process when it is turned off, but I don't get a notification of the restart ever happening.

Here is what I have so far in my config file:

God::Contacts::Email.defaults do |d|
  d
.from_email = 'em...@example.com'
  d
.from_name = 'God Notification'
  d
.delivery_method = :smtp
  d
.server_host = 'in-v3.mailjet.com'
  d
.server_port = 587
  d
.server_auth = true
  d
.server_domain = 'example.com'
  d
.server_user = 'api key'
  d
.server_password = 'api secret'
end


God.contact(:email) do |c|
  c
.name = 'Vell'
  c
.group = 'developers'
  c
.to_email = 've...@example.com'
end


God.watch do |w|
  w
.name = "mysql"
  w
.group = 'system'
  w
.interval = 1.minute # default
  w
.start = "service mysql start"
  w
.stop = "service mysql stop"
  w
.restart = "service mysql restart"
  w
.start_grace = 10.seconds
  w
.restart_grace = 10.seconds
  w
.pid_file = "/var/run/mysqld/mysqld.pid"
  w
.keepalive
  w
.behavior(:clean_pid_file)


  w
.transition(:up, :restart) do |on|
    on
.condition(:memory_usage) do |c|
      c
.interval = 20
      c
.above = 100.megabytes
      c
.times = [3, 5]
      c
.notify = {contacts: ['developers'], priority: 1, category: 'staging'}
   
end


    on
.condition(:cpu_usage) do |c|
      c
.interval = 10
      c
.above = 50.percent
      c
.times = [3, 5]
      c
.notify = {contacts: ['developers'], priority: 1, category: 'staging'}
   
end
 
end
end

Now that I am looking at this, my guess is, I am not meeting the conditions for an email to be sent out? But what condition can I right to trigger an email just on the restart that has nothing to do with memory or cpu usage? Is it simply

on.condition(:restart) do |c|
...
end

Any advice is greatly appreciated.

Thanks

Vell

unread,
Nov 13, 2015, 2:56:36 PM11/13/15
to god.rb
I see in the source code that I could do something like

on.condition(:process_exits) do |c|
  c
.pid_file = "/var/run/mysqld/mysqld.pid"

  c
.notify = {contacts: ['developers'], priority: 1, category: 'staging'}

end

or

on.condition(:always) do |c|
  c
.what = true

  c
.notify = {contacts: ['developers'], priority: 1, category: 'staging'}

end

I have tried both of these but what ends up happening is that God.rb is not restarting the process after I have turned it off and I still am not receiving any notifications. I must be missing something, I just don't know what it could be.
Reply all
Reply to author
Forward
0 new messages