Q: I was wondering if there is a way that I can specify one service to always start before the other service? For eg. I have enabled both mongodb and celiometer service to start at boot time, but I want to ensure that every time the mongodb service starts before the celiometer.
A: You can configure dependencies for certain services. For example you can make celiometer dependent on mongodb, this way celiometer will not start before mengodb.
NOTE: I am not familiar with celiometer, so for this example we will use mongodb and apache (httpd).
This should work in any version of Linux running Systemd, including but not limited to Redhat 7, CentOS 7, Fedora 20 or higher, Ubuntu, etc...
So let's say you want mongodb to start first before httpd. You can simply edit the /usr/lib/systemd/system/httpd.service file and look for the following line:
After=network.target remote-fs.target nss-lookup.target
This line tells httpd to start AFTER network remote-fs and nss-lookup targets.
Simply add you mongod.service like so:
After=network.target remote-fs.target nss-lookup.target mongod.service
This will ensure mongodb is started before httpd.
There are other options as well, for example:
(This will activate mongodb when httpd is started, but will not cause httpd to fail if mongodb fails to start)
(This will activate mongodb when httpd is started, but will cause httpd to fail if mongodb fails to start)
(This will stop mongodb when httpd is stopped)
There is a lot of information available on the interwebs to guide you through systemd, including the very well documented man pages.