jamesrwhite / minicron

🕰️ Monitor your cron jobs
GNU General Public License v3.0
2.34k stars 154 forks source link

non-zero exit code gives error [smtp] #286

Closed LaszloHont closed 7 years ago

LaszloHont commented 7 years ago

A successful job works okay:

$ /opt/minicron/minicron run --verbose true
[minicron] started running `true` at 2017-06-14 18:34:20 UTC

[minicron] finished running `true` at 2017-06-14 18:34:20 UTC
[minicron] running `true` took 0.00137769s
[minicron] `true` finished with an exit status of 0

But a failed job gives an api error, but seems to be otherwise okay (shows up in web interface):

$ /opt/minicron/minicron run --verbose false
[minicron] started running `false` at 2017-06-14 18:34:25 UTC

[API Error] 501 Syntax: HELO hostname
LaszloHont commented 7 years ago

I guess this is the mail alerting failing. Probably my fault. I will investigate.

LaszloHont commented 7 years ago

Running the server in debug mode doesn't give any clues.

Running the client in debug mode gives me this:

/opt/minicron/lib/vendor/ruby/2.2.0/gems/minicron-0.9.7.1480251919/lib/minicron/cli/commands.rb:260:in `rescue in block (2 levels) in add_run_cli_command': [API Error] 501 Syntax: HELO hostname (Minicron::CommandError)
    from /opt/minicron/lib/vendor/ruby/2.2.0/gems/minicron-0.9.7.1480251919/lib/minicron/cli/commands.rb:208:in `block (2 levels) in add_run_cli_command'
    from /opt/minicron/lib/vendor/ruby/2.2.0/gems/commander-4.4.0/lib/commander/command.rb:178:in `call'
    from /opt/minicron/lib/vendor/ruby/2.2.0/gems/commander-4.4.0/lib/commander/command.rb:178:in `call'
    from /opt/minicron/lib/vendor/ruby/2.2.0/gems/commander-4.4.0/lib/commander/command.rb:153:in `run'
    from /opt/minicron/lib/vendor/ruby/2.2.0/gems/commander-4.4.0/lib/commander/runner.rb:444:in `run_active_command'
    from /opt/minicron/lib/vendor/ruby/2.2.0/gems/commander-4.4.0/lib/commander/runner.rb:68:in `run!'
    from /opt/minicron/lib/vendor/ruby/2.2.0/gems/minicron-0.9.7.1480251919/lib/minicron/cli.rb:81:in `run'
    from /opt/minicron/lib/vendor/ruby/2.2.0/gems/minicron-0.9.7.1480251919/bin/minicron:14:in `block in <top (required)>'
    from /opt/minicron/lib/vendor/ruby/2.2.0/gems/minicron-0.9.7.1480251919/lib/minicron.rb:153:in `capture_output'
    from /opt/minicron/lib/vendor/ruby/2.2.0/gems/minicron-0.9.7.1480251919/bin/minicron:12:in `<top (required)>'
    from /opt/minicron/lib/vendor/ruby/2.2.0/bin/minicron:23:in `load'
    from /opt/minicron/lib/vendor/ruby/2.2.0/bin/minicron:23:in `<main>'

The mail server log only shows:

lost connection after HELO from...

jamesrwhite commented 7 years ago

The error handling isn't great here but like you say I think this an issue with your mail server, not minicron. Can you confirm that works with similar settings outside of minicron?

LaszloHont commented 7 years ago

I can send e-mail from other hosts on my network using the same smtp server with the same settings.

LaszloHont commented 7 years ago

The problem was that alerts.email.smtp> domain was set to the default, which is 127.0.0.1. I changed it and now it works.