Galaxy: run code when deployment fails or the app stops?

Might be a silly question, but is there anyway to run some code whenever a galaxy deployment fails or the app is stopped?

There have been a few times when something random kills my server, and I am not alerted until someone tries to load the client.

I would like to use the slack API to send out a message that broadcasts the outage.