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?

  • 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. – Marat Gainutdinov Jun 16 '20 at 14:22
  • Short answer - No. You have to provide the functionality to remove the stale lock file. – fpmurphy Jun 16 '20 at 14:31
  • Is upstart an option? – Andrew Fielden Jun 16 '20 at 14:32
  • CentOS 6 uses Upstart. See https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/6/html/migration_planning_guide/sect-networking-upstart – fpmurphy Jun 16 '20 at 14:37
  • 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. – Michael Hampton Jun 16 '20 at 14:46
  • Yup, I would go to systemd if I could, but customer insists on using CentOS 6 – Andrew Fielden Jun 16 '20 at 14:48
  • 1
    What are they going to do after November 2020, then? – Michael Hampton Jun 16 '20 at 14:57
  • Lol, good question, I'll point that one out to them! – Andrew Fielden Jun 16 '20 at 15:12

0 Answers0