mojombo / god

Ruby process monitor
http://godrb.com
MIT License
2.21k stars 546 forks source link

Can't get God.rb to send emails #225

Open vmcilwain opened 9 years ago

vmcilwain commented 9 years ago

Hello,

I am trying to set up a configuration where God.rb sends an email regardless of what even occurs. Using your events example I have tried the following:

God::Contacts::Email.defaults do |d|
  d.from_email = 'email@example.com'
  d.delivery_method = :smtp
  d.server_host = 'in-v3.mailjet.com'
  d.server_port = 465
  d.server_auth = :plain
  d.server_domain = 'some.domain'
  d.server_user = 'someuser'
  d.server_password = 'somepass'
end

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

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

  w.transition(:init, { true: :up, false: :start }) do |on|
    on.condition(:process_running) do |c|
      c.running = true
      c.notify = 'Lovell'
    end
  end

  # determine when process has finished starting
   w.transition([:start, :restart], :up) do |on|
    on.condition(:process_running) do |c|
      c.running = true
      c.notify = 'Lovell'
    end

      # failsafe
    on.condition(:tries) do |c|
      c.times = 8
      c.within = 2.minutes
      c.transition = :start
      c.notify = 'Lovell'
    end
  end
end

Unfortunately, I have not been able to get it so that God.rb tries to send an email when I stop the cron process. It restarts the process fine, but an email notification never gets sent. Curious if this is a bug.

alexandrecruz commented 8 years ago

I've faced a similar problem. Are you able to send email with any other tool? When using some cloud providers, smtp ports are blocked by default.

Please, check if its all right with your provider and/or firewall configuration.

vmcilwain commented 8 years ago

Yes this is definitely not a blocked port. I was using Monit before switching over.

Part of my issue with this is that I don't think I had a good way of testing if God was actually sending me an email. I would create a rule then try to invoke it but was never sure I actually did in order for an notification to be sent.

Sent from my iPhone

On Jan 12, 2016, at 16:50, Alexandre Cruz notifications@github.com wrote:

I've faced a similar problem. Are you able to send email with any other tool? When using some cloud providers, smtp ports are blocked by default.

Please, check if its all right with your provider and/or firewall configuration.

— Reply to this email directly or view it on GitHub.