Question sent in by: Gaurav P
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
After=network.target remote-fs.target nss-lookup.target mongod.service
Wants=mongod.service
(This will activate mongodb when httpd is started, but will not cause httpd to fail if mongodb fails to start)
Requires=mongod.service
(This will activate mongodb when httpd is started, but will cause httpd to fail if mongodb fails to start)
BindsTo=mongod.service
(This will stop mongodb when httpd is stopped)
Join Our Newsletter
Categories
- Bash Scripting (17)
- Basic Commands (50)
- Featured (7)
- Just for Fun (5)
- Linux Quick Tips (98)
- Linux Tutorials (65)
- Miscellaneous (15)
- Network Tools (6)
- Reviews (2)
- Security (32)