/etc/init.d/mongodb fail stop/restart when I use --fork like an option. But when I add parameter --pidfilepath ${MONGODB_RUN:-/var/run/mongodb}/${SVCNAME}.pid to mongod and delete --make-pidfile parameter from start-stop-daemon in start() function in /etc/init.d/mongodb all work fine. I attach fixen init script for mongodb to bugreport Reproducible: Always Steps to Reproduce: 1. Add --fort to MONGODB_OPTIONS in /etc/conf.d/mongodb 2. Start mongodb with rc-service mongodb start 3. Try to restart or stop service
Created attachment 357452 [details] Fixed mongodb init script
Comment on attachment 357452 [details] Fixed mongodb init script --- files/mongodb.initd-r1 2013-08-16 14:54:44.000000000 +0200 +++ - 2013-08-31 14:48:42.425150115 +0200 @@ -20,7 +20,7 @@ fi ebegin "Starting ${SVCNAME}" - start-stop-daemon --background --start --make-pidfile \ + start-stop-daemon --background --start \ --pidfile ${MONGODB_RUN:-/var/run/mongodb}/${SVCNAME}.pid \ ${USEROPT} ${MONGODB_USER:-mongodb} \ --exec ${MONGODB_EXEC:-/usr/bin/mongod} \ @@ -28,6 +28,7 @@ --port ${MONGODB_PORT:-27017} \ --dbpath ${MONGODB_DATA:-/var/lib/mongodb} \ --unixSocketPrefix ${MONGODB_RUN:-/var/run/mongodb} \ + --pidfilepath ${MONGODB_RUN:-/var/run/mongodb}/${SVCNAME}.pid \ --logappend --logpath /var/log/mongodb/${SVCNAME}.log \ ${MONGODB_OPTIONS} eend $?
And in that script have another strange solution. mongodb can forking and backgrounding by himself. It mean the --background option for start-stop-daemon not needed, instead of this might add --fork parameter to mongod.
--- /usr/portage/dev-db/mongodb/files/mongodb.initd-r1 2013-08-16 15:54:44.000000000 +0300 +++ /etc/init.d/mongodb 2013-08-31 16:05:19.339834952 +0300 @@ -20,14 +20,16 @@ fi ebegin "Starting ${SVCNAME}" - start-stop-daemon --background --start --make-pidfile \ + start-stop-daemon --start \ --pidfile ${MONGODB_RUN:-/var/run/mongodb}/${SVCNAME}.pid \ ${USEROPT} ${MONGODB_USER:-mongodb} \ --exec ${MONGODB_EXEC:-/usr/bin/mongod} \ -- \ + --fork \ --port ${MONGODB_PORT:-27017} \ --dbpath ${MONGODB_DATA:-/var/lib/mongodb} \ --unixSocketPrefix ${MONGODB_RUN:-/var/run/mongodb} \ + --pidfilepath ${MONGODB_RUN:-/var/run/mongodb}/${SVCNAME}.pid \ --logappend --logpath /var/log/mongodb/${SVCNAME}.log \ ${MONGODB_OPTIONS} eend $?
In /etc/init.d/mongos script same: --- /usr/portage/dev-db/mongodb/files/mongos.initd-r1 2013-08-16 15:54:44.000000000 +0300 +++ /etc/init.d/mongos 2013-08-31 16:08:38.649834929 +0300 @@ -30,13 +30,15 @@ fi ebegin "Starting ${SVCNAME}" - start-stop-daemon --background --start --make-pidfile \ + start-stop-daemon --start \ --pidfile ${MONGOS_RUN:-/var/run/mongodb}/${SVCNAME}.pid \ ${USEROPT} ${MONGOS_USER:-mongodb} \ --exec ${MONGOS_EXEC:-/usr/bin/mongos} \ -- \ + --fork \ --port ${MONGOS_PORT:-27018} \ --unixSocketPrefix ${MONGOS_RUN:-/var/run/mongodb} \ + --pidfilepath ${MONGOS_RUN:-/var/run/mongodb}/${SVCNAME}.pid \ --logappend --logpath /var/log/mongodb/${SVCNAME}.log \ --configdb ${MONGOS_CONFIGDB} \ ${MONGOS_OPTIONS}
Hi zunkree, I understand your problem but I don't understand why you would use --fork in the confd. The init script itself works fine if you don't use conflicting command line options doesn't it ?
Mongo can daemonize by himself with --fork option and not needed --backgroud via start-stop-daemon. Why we need duplicate a program functionality?
(In reply to zunkree from comment #7) > Mongo can daemonize by himself with --fork option and not needed --backgroud > via start-stop-daemon. Why we need duplicate a program functionality? You have a point for sure. What then if the user decided to use --pidfilepath as well ? Having s-s-d handle forking and the pid makes sure openrc is always right about the status of mongodb, whatever the user would want to mess with.