Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MongoDB instance stops running on Webfaction

I am running MongoDB on Webfaction as a database of a Django app . Problem is I have to keep my SSH terminal session open and use this syntax to keep running MongoDB .

mongod --dbpath ~/webapps/mongo_db/mongodb/ --port 31706

As soon as I close my terminal the connection to database dies . What is the solution to keep mongodb running always on server ?

like image 619
peter Avatar asked Feb 15 '15 10:02

peter


1 Answers

WebFaction is a shared host, so you can't run mongod as a system service.

Instead, use the --fork option when starting mongod, like so:

mongod --dbpath ~/webapps/mongo_db/mongodb/ --port 31706 --fork \
       --logpath $HOME/logs/user/mongo_db.log

When you need to stop it, run:

mongod --dbpath ~/webapps/mongo_db/mongodb/ --port 31706 --shutdown

Hope that helps!

like image 119
Sean F Avatar answered Sep 29 '22 10:09

Sean F