Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

This command:

mongod --fork --dbpath ../data --smallfiles --logpath ../data/mongo.log

runs perfectly from terminal, while in directory /mongo/bin/

But, when I use same command and directory for upstart session job file (at $HOME/.config/upstart):

# mongod_service - mongoDB job file
description "MongoDB service"
author "admin"

# When to start the service
start on runlevel [2345]

# When to stop the service
stop on runlevel [016]

# Automatically restart process if crashed
# respawn

# Essentially lets upstart know the process will detach itself to the background
expect fork

# working directory
chdir /mongo/bin/

# log this job
console log

# Start mongod as daemon
exec /mongo/bin/mongod --fork --dbpath /mongo/data --smallfiles --logpath /mongo/data/mongo.log

Update: Changed job file and It starts fine now, but when I try to stop it with initctl stop mongod-service, the command never completes !.

Can anyone suggest how to make this work ?

share|improve this question
    
are you sure you can use relative paths? Also: for debugging see this: askubuntu.com/questions/36200/how-to-debug-upstart-scripts –  Rinzwind May 20 '13 at 13:57
    
@Rinzwind Replaced with absolute paths, no effect. –  user117 May 20 '13 at 14:07
add comment

1 Answer

up vote 1 down vote accepted

Even if you are using a version of MongoDB built from Git, you can still reuse the official upstart config file:

https://github.com/mongodb/mongo/blob/master/debian/mongod.upstart

and update it as required.

share|improve this answer
    
Yes, I'm always keeping a latest build from the git clone and configuring custom database paths etc. Also updated question. –  user117 May 22 '13 at 14:24
    
Updated answer to reflect your response. –  David Edwards May 22 '13 at 15:16
    
Thanks. I'll need to make some edits though. –  user117 May 22 '13 at 15:36
    
Hmmm.. it uses a daemon starter, which is strange because upstart was supposed to be the alternative. –  user117 May 22 '13 at 15:47
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.