Upstart: defining service dependencies / priorities

5,147

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

### BEGIN INIT INFO
# 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.
### END INIT INFO

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:
5,147

Related videos on Youtube

shevron
Author by

shevron

Updated on September 18, 2022

Comments

  • shevron
    shevron almost 2 years

    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?