Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 483052 - dev-db/mongodb - init.d script fails to stop/restart `mongodb --fork'
Summary: dev-db/mongodb - init.d script fails to stop/restart `mongodb --fork'
Status: RESOLVED WONTFIX
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Server (show other bugs)
Hardware: All All
: Normal normal
Assignee: Ultrabug
URL:
Whiteboard:
Keywords: PATCH
Depends on:
Blocks:
 
Reported: 2013-08-30 19:47 UTC by zunkree
Modified: 2014-02-17 09:07 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Fixed mongodb init script (mongodb,1.24 KB, text/plain)
2013-08-30 19:48 UTC, zunkree
Details

Note You need to log in before you can comment on or make changes to this bug.
Description zunkree 2013-08-30 19:47:14 UTC
/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
Comment 1 zunkree 2013-08-30 19:48:49 UTC
Created attachment 357452 [details]
Fixed mongodb init script
Comment 2 Jeroen Roovers (RETIRED) gentoo-dev 2013-08-31 12:48:50 UTC
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 $?
Comment 3 zunkree 2013-08-31 12:59:34 UTC
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.
Comment 4 zunkree 2013-08-31 13:05:46 UTC
--- /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 $?
Comment 5 zunkree 2013-08-31 13:09:31 UTC
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}
Comment 6 Ultrabug gentoo-dev 2013-10-21 09:52:11 UTC
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 ?
Comment 7 zunkree 2013-10-31 09:27:12 UTC
Mongo can daemonize by himself with --fork option and not needed --backgroud via start-stop-daemon. Why we need duplicate a program functionality?
Comment 8 Ultrabug gentoo-dev 2013-11-06 13:57:05 UTC
(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.