Hi Tom,<br><br>As per the upstart cookbook [1], you'll likely need a few extra stanzas.<br><br>According to the 'expect' section [2] you'll probably need to add 'expect daemon' to allow upstart to track the proper process ID when mongodb forks in order to daemonize.<br>

<br>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 [3] 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' [4] 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.<br>

<br>There are a lot of good resources in the cookbook [1], so hopefully it will answer any other questions you might have.<br><br>Cheers,<br>Evan<br><br>[1] <a href="http://upstart.ubuntu.com/cookbook/">http://upstart.ubuntu.com/cookbook/</a><br>

[2] <a href="http://upstart.ubuntu.com/cookbook/#expect">http://upstart.ubuntu.com/cookbook/#expect</a><br>[3] <a href="http://upstart.ubuntu.com/cookbook/#changing-user">http://upstart.ubuntu.com/cookbook/#changing-user</a><br>

[4] <a href="http://upstart.ubuntu.com/cookbook/#script">http://upstart.ubuntu.com/cookbook/#script</a><br><br><div class="gmail_quote">On Sat, Mar 17, 2012 at 7:32 AM, Tom <span dir="ltr"><<a href="mailto:tommedema@gmail.com">tommedema@gmail.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi folks,<br>
<br>
I'm trying to run mongod as a deamon using upstart under the<br>
unprivileged mongouser account.<br>
<br>
The following appears to work great:<br>
<br>
# Mongodb Ubuntu upstart file at /etc/init/mongodb.conf<br>
<br>
description "MongoDB deamon"<br>
<br>
pre-start script<br>
    mkdir -p /home/mongouser/data/db<br>
    mkdir -p /home/mongouser/data/logs<br>
end script<br>
<br>
start on runlevel [2345]<br>
stop on runlevel [06]<br>
<br>
exec su -s /bin/sh -c 'exec "$0" "$@"' mongouser --<br>
/home/mongouser/Applications/mongodb/bin/mongod --fork --journal<br>
--nohttpinterface --dbpath /home/mongouser/data/db --logpath<br>
/home/mongouser/data/logs/mongodb.log --logappend --port 30000<br>
<br>
------------<br>
<br>
When I reboot the system mongod indeed starts properly. However, here<br>
are the issues:<br>
1. when I do sudo status mongodb I get "stop/waiting" even though it is running<br>
2. when I do sudo start mongodb it starts the deamon again, even<br>
though mongod is already running.<br>
<br>
Can anyone tell me what is going wrong here?<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
upstart-devel mailing list<br>
<a href="mailto:upstart-devel@lists.ubuntu.com">upstart-devel@lists.ubuntu.com</a><br>
Modify settings or unsubscribe at: <a href="https://lists.ubuntu.com/mailman/listinfo/upstart-devel" target="_blank">https://lists.ubuntu.com/mailman/listinfo/upstart-devel</a><br>
</font></span></blockquote></div><br>