Hi Jens, 2014-03-20 17:41 GMT+00:00 Jens Rantil <[email protected]>:
> Hi, > > I have an HTTP server daemon process that I start using upstart. When I > start it I'd like it to wait for at most 60 seconds for an HTTP check to > return 200. If it doesn't return within 60 I'd like to fail "start myapp", > otherwise I'd like to return "start myapp" as soon as I get a correct HTTP > response. > > I've been trying to use > > post-start script > /bin/my-healthcheck --max-wait 60 > if [ $? -ne 0 ]; then > stop > exit 1 > fi > end script > > But "stop; exit 1" doesn't seem to stop my service. > Your script is subtly incorrect; Upstart uses '/bin/sh -e' to run all script sections so if my-healthcheck fails, that post-start script shell will *immediately* exit 1, and stop will never be called. See: - Behaviour of 'set -e' in sh(1). - http://upstart.ubuntu.com/cookbook/#develop-scripts-using-bin-sh To handle this, you could do something like: post-start script /bin/my-healthcheck --max-wait 60 || { stop; exit 1; } end script > > Can this be done using upstart? Or will I need to `exec myservice_safe` > that initiates a check and my main script? Or use events? > > Thanks, > Jens > > PS. I've cross posted my question here: > https://serverfault.com/questions/583426/why-is-this-upstart-script-not-stopping-my-process > > -- > upstart-devel mailing list > [email protected] > Modify settings or unsubscribe at: > https://lists.ubuntu.com/mailman/listinfo/upstart-devel Kind regards, James. -- James Hunt ____________________________________ #upstart on freenode http://upstart.ubuntu.com/cookbook https://lists.ubuntu.com/mailman/listinfo/upstart-devel
-- upstart-devel mailing list [email protected] Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/upstart-devel
