How can I receive an email when an upstart monitored script respawns?
My upstart config looks something like this
start on filesystem
stop on runlevel S
respawn
exec /path/to/my/script
When this script dies and is respawned I would like to receive an email. Is this possible, or am I using the wrong tool for the job?
Thanks!
Solution 1:
You could write a post-start stanza to send e-mail(s).
# An Upstart script to manage the foo service
respawn
post-start script
echo "my-foo service started at `date +"%F %T.%N"`" | mail -s "My-foo Service Started" [email protected]
echo "my-foo service started at `date +"%F %T"`" | mail -s "My-foo Service Started" [email protected]
end script
exec -u foo-user /usr/local/bin/foo