1

I'm using Fabric to manage remote deployment of my blog that uses the static site generator Pelican. Whenever I drop a new file in Dropbox, I use Dropbox webhooks to launch a series of tasks that are on a Heroku server. The tasks are managed using Fabric.

Because this is all done remotely, I currently have to manually inspect the logs whenever I realize that something went wrong. I'd like Fabric to email me whenever it aborts due to an error.

How can I catch a Fabric abort so that I can have it send me an email?

jdotjdot
  • 16,134
  • 13
  • 66
  • 118

1 Answers1

1

You can catch SystemExit exception thrown by a failing task and then send an email in the exception handling block.

See also relevant topics:

Community
  • 1
  • 1
alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195
  • hanks, this is helpful. To do this though, I'd have to wrap every call in a `try/except` block or create one "run everything" function in a `try/except` block. Is there any way in the Fabric settings to do this or somewhere top-level, similar to how you can set `env.warn_only`? – jdotjdot Jun 06 '14 at 17:33
  • @jdotjdot I'd wrap every task into `try/except` decorator, see for example: http://stackoverflow.com/questions/9386592/repetitive-try-and-except-clauses. – alecxe Jun 06 '14 at 17:39
  • Ah--great idea. Thanks; hadn't thought of that. – jdotjdot Jun 06 '14 at 17:44