I had the same question, and I also found a different answer. The author lists 4 options to accomplish this, of which I like the first one best:
Use initclt emit myservice-started
to signal the completion of your dependent service's startup. In the linked answer, it is suggested to add this line to the end of the dependency service's init.d
script, but I prefer a different method.
I like to create a new inid.d
script named myservice-started
that only contains a start
section. Using the appropriate commenting style in the file's header, I declare that it depends on $myservice
to be started. In the start
section, I tell upstart about myservice
being started. You can install it with update-rc.d
.
I like this solution because it is not intrusive; if an update changes any of the existing init.d
scripts, it won't affect these additional scripts. But remember that changes to your upstart scripts are required.
It might look like this:
#!/bin/sh -e
### BEGIN INIT INFO
# Provides: myservice-started
# Required-Start: $myservice
# Default-Start: 2 3 4 5
# Short-Description: send upstart signal after starting myservice
# Description: myservice needs to run before some upstart services can run
### END INIT INFO
. /lib/lsb/init-functions
case "$1" in
start)
log_daemon_msg "Signaling myservice started..." "myservice-started"
initctl emit myservice-started --no-wait
;;
*)
log_action_msg "Usage: /etc/init.d/myservice-started start"
exit 1
;;
esac
exit 0
Your upstart script waiting for myservice can listen for the myservice-started
event:
start on myservice-started