March 2011
I got this from the portmap-wait
job by Clint Byrum.
If an upstart job needs to wait for another (e.g. ssh
), we can create a special wait job
:
# lwp-ssh-wait - wait-service for ssh description "wait-service for ssh" # # Long description: # This job wil hang forever unless ssh comes up # Jobs wanting to wait for ssh can call this one, like so: # # start lwp-ssh-wait WAITER=otherjob # # Have this job killed when ssh is started (or stopped) stop on started ssh or stopped ssh author "Jurjen Bokma <j.bokma@rug.nl>" # If we finish with status 2 (by being killed), that is ok normal exit 2 task instance $WAITER script status ssh|grep -q 'start/running' && exit 0 start ssh || true while sleep 1800 ; do :; done end script
If the job waited for -i.c. ssh- is started already, the wait job exits immediately. | |
We may or may not want to do this: start the job being waited for from the wait job. | |
I any case, | |
This will put the job to indefinite sleep, but the | |
Having |
Now another job, one that needs to wait for ssh to be present, can call the wait job like this:
# lwp-do-something-else description "do something else" # # Long description: # # Wait scripts start on starting rsyslog author "Jurjen Bokma <j.bokma@rug.nl>" task pre-start script start lwp-ssh-wait WAITER=lwp-fetch-kerberos-credentials end script script echo "something else being done" end script