Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

habitat daemons should mail us when there's an unhandled exception #197

Open
danielrichman opened this issue Jul 28, 2012 · 10 comments
Open
Assignees

Comments

@danielrichman
Copy link
Member

see habitat/utils/immortal_changes.py

@danielrichman
Copy link
Member Author

See first code snippet in http://flask.pocoo.org/docs/errorhandling/ : add a SMTPHandler to the standard python logging object; job done. Errors now get mailed to you.

Trivially added to config and startup.setup_logging

@danielrichman
Copy link
Member Author

@danielrichman
Copy link
Member Author

also good would be a supervisord event listener ( http://supervisord.org/events.html#example-event-listener-implementation ) that emails us if a daemon stops, fails to start, e.t.c.

@danielrichman
Copy link
Member Author

This is done for the parser and spacenearus daemons (pending deployment) but is still TODO for calendar, transition, maybe couch named python and the supervisord event listener thing.

@danielrichman danielrichman reopened this Sep 17, 2012
@danielrichman
Copy link
Member Author

dug through the code and found this snippet in ~habitat/old/habitat-calendar/blah/cal.py; saving it here in case it's lost in spring cleaning or something

+ADMINS = ['[email protected]', '[email protected]']
+if not app.debug:
+    import logging
+    from logging.handlers import SMTPHandler
+    mail_handler = SMTPHandler('127.0.0.1', '[email protected]', ADMINS
+                               'calendar error')
+    mail_handler.setLevel(logging.ERROR)
+    app.logger.addHandler(mail_handler)
+
+    @app.route("/test_error")
+    def test_error():
+        raise AssertionError("This is a test error message")

Though we should probably import and use habitat.setup_logging instead somehow with the global habitat.yml file (yay).

@danielrichman
Copy link
Member Author

http://pypi.python.org/pypi/superlance provides 'crashmailbatch' and 'failmailbatch' which do pretty much exactly what we want for a supervisord event listener.

@danielrichman
Copy link
Member Author

superlance deployed. Config was:

[eventlistener:crashmailbatch]
user=nobody
command=/opt/superlance/bin/crashmailbatch -t [email protected] -f [email protected]
events=PROCESS_STATE,TICK_60

[eventlistener:fatalmailbatch]
user=nobody
command=/opt/superlance/bin/fatalmailbatch -t [email protected] -f [email protected]
events=PROCESS_STATE,TICK_60

@adamgreig
Copy link
Member

🆒 👍

@danielrichman
Copy link
Member Author

List of daemons/things that might need to email us

Done:

  • spacenearus uploader
  • parser
  • supervisord
  • transition (wsgi)
  • calendar

Not done:

  • couch view server

@danielrichman
Copy link
Member Author

18:39 < DanielRichman> you think emails from the parser are bad
18:39 < DanielRichman> if the view server is sad and can email you about it
18:39 < DanielRichman> you're gonna know

Couch view server being able to email us would be suicide.

Maybe we want to investigate one of:

  • getsentry/airbrake/hoptoad/exceptional/errbit
  • logging handler that throttles itself
  • log serious stuff to a 'paniclog' (like exim) which is checked by a cronjob or monit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants