Deployd + MongoDB not working - node.js

I have problem with Deployd and MongoDB, I have fully configured deployd and fully functional mongodb, I can run mongod without any problems , mongoDB is in .bashrc file in my path.
The most interesting part is that my deployd used to work just fine, I was creating my first deployd app today, then I went to dentist got back to my home, turned on my PC and it's not working anymore.
When I try to debug dpd I get this message:
mongod starting mongod +0ms
mongod error: 1 +6ms
mongod killing mongod +1ms
Any ideas?

Problem solved, the problem was that I used wrong installation guide for mongoDB,
I used this guide: http://docs.mongodb.org/manual/tutorial/install-mongodb-on-linux/
This installation is pretty small, and it doesn't include things like logs or configuration files for mongodb in /var/ or /etc/ folders.
If you have Linux Ubuntu you should use this guide:
http://docs.mongodb.org/manual/tutorial/install-mongodb-on-ubuntu/
and everything should be ok.

Related

how to restart mongodb in terminal?

I installed mongodb in VS code by npm install mongodb. And again I downloaded mongodb from official website and installed it as a windows service since I don't know if installing in vscode with npm is enough. It worked for a while.
and now it doesn't work as my database connection with mongoose fails and nothing is running in 27017 port in localhost. Seems like server stopped.
how to restart mongodb server? what's the CLI/terminal command etc for that?
On debian/ubuntu
sudo service mongod restart
Go to services via start button and check for the MongoDB services shown in below pic. And rest steps you can follow which #apoorva has mentioned.
Open a mongo shell and execute,
use admin
db.shutdownServer()
You may start again with mongod.
Learn more here, https://docs.mongodb.com/manual/tutorial/manage-mongodb-processes/#StartingandStoppingMongo-SendingshutdownServer%28%29messagefromthemongoshell
If You Installed MongoDB as a Windows Service
The MongoDB service is started upon successful installation.(please check on the below path)
To begin using MongoDB, connect a mongo.exe shell to the running MongoDB instance. Either:
From Windows Explorer/File Explorer, go to
C:\Program Files\MongoDB\Server\4.4\bin\ directory and double-click on mongo.exe.
Or, open a Command Interpreter with Administrative privileges and run:
"C:\Program Files\MongoDB\Server\4.4\bin\mongo.exe"
for more details check. : https://treehouse.github.io/installation-guides/windows/mongo-windows.html
Also, you first need to start the mongodb daemon for your connections to listen then you should connect using mongoose.

I'm having some trouble while setting MongoDB to run on the cloud

I'm new to Node.Js and all of its "accessories", and I've been trying to set up a Mongodb database, but there are so many ways to do it, it seems, that I've been quite stuck because I'm not sure what goes where and when, anyway, I have a snapshot of the code and the prompt, everything else on the code works.
Also I want to use the mongo cloud database while hosting my node.js on heroku (I got the heroku deployment running), so would I be able to test my database both when doing "node app.js" on my local machine and when I deploy it on heroku?
Additional information:
I NPM'ed mongojs and mongodb
I'm using some sort of cluster on mongodb.atlas (I'm clueless on this)
I set up the mongodb shown on the snapshot above using the option: Clusters > Connect > Connect your application > Short SRV connection string
I had a similar situation with MongoDB working on Heroku but not locally, getting that same error message. Here's the steps I took.
Make sure the database path is configured correctly - it is /data/db by default. I had to run mkdir -p /data/db; you can also choose to manually set that path.
Make sure that MongoDB is running locally before you start your server. You may have to run mongod in the command line to start it; alternately, for Node.js, you can go to package.json and edit your launch configuration by adding "pre-start: 'mongod'" to "scripts," which automatically starts MongoDB when you start your server.

Can't run Rocket.Chat server on Ubuntu without Docker

I've been following this tutorial to install Rocket.Chat on Ubuntu:
https://github.com/RocketChat/Rocket.Chat/wiki/Deploy-Rocket.Chat-without-docker
Everything looks good until I try to run the server with node main.js:
Error: failed to connect to [localhost:27017]
at Object.Future.wait (/home/gregoire/Rocket.Chat/programs/server/node_modules/fibers/future.js:398:15)
at new MongoConnection (packages/mongo/mongo_driver.js:213:1)
localhost could also be 127.0.0.1 or my IP address, it doesn't change anything. Sounds like an error coming from MongoDB.
So I tried to run with sudo and the error I'm getting is different:
Error: MONGO_URL must be set in environment
I follow the tutorial, this variable has been set using export:
export ROOT_URL=http://localhost/
export MONGO_URL=mongodb://localhost:27017/rocketchat
export PORT=80
EDIT:
I needed to start mongod to then run the main.js. But I also got an error:
mongodb failed to connect to 127.0.0.1
I made some research and found that I had a missing folder. I used this command to create it and then started mongod:
mkdir -p /data/db
It worked after that, but it's not implied in the tutorial. I'm currently repeating the setup on a server and I'm having the same problem: /data/db is missing.
Disclaimer: I work for Rocket.Chat.
Are you sure mongodb is running? Can you type mongo and see if you can get into a mongoDB shell? If it's running, can you please confirm it's running on port 27017?
You can also go to https://demo.rocket.chat and join #support channel or #dev, where you'll find quite a few developers willing to help you out.

Deploying new node.js keystoneJS app on Digital Ocean

I am close to deploying my first node app (KeystoneJS) + mongoDb and I was thinking of using Digital Ocean. This would be the first node app I have deployed and first time using Digital Ocean. I've tried to find tutorials or guides from other people deploying an app built on keystone but have failed to uncover one. I would greatly appreciate it someone could share the steps they used to deploy a node app + keystone + mongo they built.
Thank you.
It's quite simple yet nobody explains in detail.
I had to bang my head for a while and I got it all figured out.
I'm not a Linux specialist.
First, you set up a droplet with MEAN configuration.
That takes care of the MongoDB and the Node setup.
Then you'll have to make Mongo to run as process:
Mongo
Step 1: Remove lock file.
sudo rm /var/lib/mongodb/mongod.lock
Step 2: Repair mongodb.
mongod --repair
Step 3:
sudo mongod --port 27017 --fork --logpath /var/log/mongodb.log
Step 4: Check status of mongodb.
mongo
After that, once you moved your keystone project into your opt/mean folder, running node keystone in your terminal should do it.
You'll see something like:
KeystoneJS Started:<br/>
[your project name] is ready on port 3000
I highly recommend you start by running your project on your local machine first and move it after you're able to run it on localhost:3000.

how to start mongodb with Node.js using monk

I'm new to mongodb and nodeJS. Currently I've made a sample application using node.js, monk and mongodb. However to make it work, I have to open 2 cmd windows.The first one is go to mongodb folder, run: mongod --dbpath myprojectpath. The second is to go to myprojectpath, run: npm start. Starting mongodb and point to the working path manually seems is not the right way for a web application. But how can I let mongoDB point to my project automatically and run, like SQL server?
It's possible, but keep in mind, that your two mentioned shell calls are different.
The first one will start your mongoDb server with data directory. You could place your datafiles in the default directory (/data/db) like it's described in the docs. If your datafiles are in the default directory you could simply start it with mongod that would save you from linking your datafiles.
For a quick startup you could run something like:
#!/bin/sh
mongod;
cd <your project> && node app.js;
To boot up your app.

Resources