Mongodb upstart script
eapache at gmail.com
Sat Mar 17 12:22:18 UTC 2012
As per the upstart cookbook , you'll likely need a few extra stanzas.
According to the 'expect' section  you'll probably need to add 'expect
daemon' to allow upstart to track the proper process ID when mongodb forks
in order to daemonize.
Also, I'm not sure what you're trying to do with the "su -s /bin/sh -c
exec". If you're trying to change users  you probably shouldn't be using
su. If you need the program to be run in a shell environment for some
reason, you can simply use 'script'  instead of exec. If you're simply
using it to fork so that it daemonizes properly instead of only forking
once, you can change 'expect daemon' to 'expect fork' and upstart will
track the process ID correctly.
There are a lot of good resources in the cookbook , so hopefully it will
answer any other questions you might have.
On Sat, Mar 17, 2012 at 7:32 AM, Tom <tommedema at gmail.com> wrote:
> Hi folks,
> I'm trying to run mongod as a deamon using upstart under the
> unprivileged mongouser account.
> The following appears to work great:
> # Mongodb Ubuntu upstart file at /etc/init/mongodb.conf
> description "MongoDB deamon"
> pre-start script
> mkdir -p /home/mongouser/data/db
> mkdir -p /home/mongouser/data/logs
> end script
> start on runlevel 
> stop on runlevel 
> exec su -s /bin/sh -c 'exec "$0" "$@"' mongouser --
> /home/mongouser/Applications/mongodb/bin/mongod --fork --journal
> --nohttpinterface --dbpath /home/mongouser/data/db --logpath
> /home/mongouser/data/logs/mongodb.log --logappend --port 30000
> When I reboot the system mongod indeed starts properly. However, here
> are the issues:
> 1. when I do sudo status mongodb I get "stop/waiting" even though it is
> 2. when I do sudo start mongodb it starts the deamon again, even
> though mongod is already running.
> Can anyone tell me what is going wrong here?
> upstart-devel mailing list
> upstart-devel at lists.ubuntu.com
> Modify settings or unsubscribe at:
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the upstart-devel