Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 1 down vote accepted

At the beginning of the init script there is a INIT INFO block:

# Provides:          skeleton
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Example initscript
# Description:       This file should be used to construct scripts to be
#                    placed in /etc/init.d.

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, like mongod in your case and, if this is the case, on Required-Stop you will set the services that must be stopped before you stop your service.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.