My current setup:
mongodb
me@server:/lib/systemd/system$ cat mongodb.service
[Unit]
Description=An object/document-oriented database
Documentation=man:mongod(1)
[Service]
User=mongodb
ExecStart=/usr/bin/mongod --config /etc/mongodb.conf
[Install]
WantedBy=multi-user.target
mongodb.homepage1
me@server:/lib/systemd/system$ cat mongodb.homepage1.service
[Unit]
Description=An object/document-oriented database
Documentation=man:mongod(1)
[Service]
User=mongodb
ExecStart=/usr/bin/mongod --config /etc/mongodb.homepage1.conf
[Install]
WantedBy=multi-user.target
mongodb.homepage2
me@server:/lib/systemd/system$ cat mongodb.homepage2.service
[Unit]
Description=An object/document-oriented database
Documentation=man:mongod(1)
[Service]
User=mongodb
ExecStart=/usr/bin/mongod --config /etc/mongodb.homepage2.conf
[Install]
WantedBy=multi-user.target
As you can see, all three files have the same structure.
Still mongodb
starts on boot, whereas mongodb.homepage1
and mongodb.homepage2
do not.
Manual start works:
sudo reboot
# ... server reboots ...
sudo service mongodb start # not necessary, because this one starts automatically
sudo service mongodb.homepage1 start
sudo service mongodb.homepage2 start
All 3 are running on different ports configured through their different configuration files.
Why don't they start on boot?
Make sure you have enabled your 2 custom services. To view a list of enabled and disabled services, you use this command:
If they are disabled or not in the list, enable them: