How can I return non-zero from an upstart job if it fails to launch the first time? I suspect that respawn might be the culprit here, but perhaps not.
The reason I want respawn is because myscript.py is a serivce that can exit for two separate reasons:
- Bad configuration. (fails at startup)
- Unexpected exception when processing data. (Runtime failure)
So I'd very much like to keep the second behavior, without the first if at all possible.
description "MyJob"
respawn
start on runlevel [2345]
stop on runlevel [!2345]
script
exec python /usr/local/bin/myscript.py
end script
Anyway, I could live with the dual behaviors if the initial restart or start commands return non-zero when the script exits within a small window.
How can I do this?