MongoDB instance stops working in Webfaction

I am running MongoDB in Webfaction as a Django application database. The problem is that I have to keep the SSH terminal session open and use this syntax to continue MongoDB.

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

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

+6
source share
2 answers

WebFaction is a shared host, so you cannot start mongod as a system service.

Instead, use the --fork when starting mongod , for example:

 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 this helps!

+7
source

I could solve this with

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

We can also set the cron task to check it from time to time.

0
source

Source: https://habr.com/ru/post/982513/


All Articles