0

I'm running a mongod process on my Centos 6.8 box, and I want to provide some level of resilience in the event of process death. So I created an entry in my /etc/inittab -

md:2345:respawn:/usr/bin/mongod

To test this, I killed the process, and expected it to restart. But it didn't.

$ service mongod status
mongod dead but subsys locked

This message indicates there's a pid file present /var/run/mongodb/mongod.pid, so init thinks the process is still running.

Question: Is there an automatic way for init to remove the pid file and restart mongod?

8
  • Have you tried to edit your entry: md:2345:respawn:/usr/bin/mongod to something like this? md:2345:respawn:/usr/bin/env /mongo_start_script.sh in order to include inside the script desired commands like kill mongodb and etc. Jun 16, 2020 at 14:22
  • Short answer - No. You have to provide the functionality to remove the stale lock file.
    – fpmurphy
    Jun 16, 2020 at 14:31
  • Is upstart an option? Jun 16, 2020 at 14:32
  • 1
    CentOS 6 just used upstart for SysV compatibility and uses very little of its other functionality (as it turned out to be basically garbage and so everyone abandoned it). It's also very close to end of life and it's quite surprising you're still running it. You would not have this problem on CentOS 7 (or 8, which you should just go directly to at this point) as they use systemd, which doesn't suffer this problem and can automatically restart crashed daemons. Jun 16, 2020 at 14:46
  • 1
    What are they going to do after November 2020, then? Jun 16, 2020 at 14:57

0

You must log in to answer this question.

Browse other questions tagged .