I am working on an app which runs several services / daemons using upstart. These should start on system startup, but only after the DB server (in our case mongo) was started. I am looking for the right upstart configuration to cause a service to either cause mongo to be started when it is started or only start after mongo has started.
I do not want to modify any upstart configuration which is not a part of our own software (e.g. modify the mongo upstart config).
One direction was to add to our code something like:
start on started mongod and runlevel [2345]
Or something similar, but I think this is not exactly what I want: I want "mongo started" to be a requirement for our services, I do not want it to trigger my scripts to start. E.g. I do not want that if someone manually stops our services and re-starts mongo, for example, our scripts would unintentionally start as well.
Any suggestions?
Best Answer
At the beginning of the init script there is a
INIT INFO
block:The first three lines is where you have to change to do what you want to do.
Provides
states what service your script is serving.Required-Start
is where you will put the dependencies, likemongod
in your case and, if this is the case, onRequired-Stop
you will set the services that must be stopped before you stop your service.