Public bug reported:

After non-clean shutdown /var/lib/mongodb/mongodb.lock avoid mongodb to
start properly. Adding next line to /etc/init/mongodb.conf  (anywhere in
the script section before launching the daemon) fixes the problem:

ps -eo %u | grep -q ^mongodb$ || rm -f /var/lib/mongodb/mongod.lock


Explained:
-   ps -ef  %u                                                       -> print 
all uid for current processes.
-   grep -q ^mongodb                                       ->  test if the 
mongo service is actually running. "mongodb" is the same value passed to 
start-stop-daemon  in the --chuid parameter.
-   || rm -f /var/lib/mongodb/mongod.lock   -> Unconditionally remove the lock 
file if test failed.


Ex1:

script
  ENABLE_MONGODB="yes"
  UID="mongodb" # <- Reuse value
  if [ -f /etc/default/mongodb ]; then . /etc/default/mongodb; fi
  ps -eo %u | grep -q "^${UID}$"  || rm -f /var/lib/mongodb/mongod.lock
  if [ "x$ENABLE_MONGODB" = "xyes" ]; then exec start-stop-daemon --start 
--quiet --chuid ${UID} --exec  /usr/bin/mongod -- --config /etc/mongodb.conf; fi
end script

** Affects: mongodb (Ubuntu)
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of Ubuntu
Server Team, which is subscribed to mongodb in Ubuntu.
https://bugs.launchpad.net/bugs/1251654

Title:
  Remove /var/lib/mongodb/mongodb.lock trying to start mongodb service

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/mongodb/+bug/1251654/+subscriptions

-- 
Ubuntu-server-bugs mailing list
Ubuntu-server-bugs@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/ubuntu-server-bugs

Reply via email to