Deploying new node.js keystoneJS app on Digital Ocean - node.js

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.

Related

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.

Do I need to manually restart my app on EC2 if the server restarts?

This is my first time with EC2 so keep that in mind. I spun an EC2 instance and put a really basic nodejs/express app up on it. I connected to the ec2 server via the terminal on my personal computer and ran node app.js to start the app and everything is running fine. The part I am confused about is how long this will run for. Ideally, I just want it to sit there and not touch it and have it run for hopefully years. Will it do this? If not what do I need to do? What if the server restarts for some reason? What is the common practice here?
Go to root directory of your project and type this command to run the server permanently.
sudo npm install forever -g
forever start -c "node app.js" ./
This blog may be helpful, in setting up node for production environments

Deployd + MongoDB not working

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.

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.

Nodemon + Vagrant + Mongodb

I'm using Vagrant for developing my node apps, I have installed nodemon, mongodb and fwded ports 3000:3000 (for my apps) and 27017:27017 (for MongoDB connection).
If I run
nodemon server.js
And I can access my app on http://localhost:3000, but every time I make a change on my Vm's DB I have to type
rs
For the changes on the DB to take effect on http://localhost:3000
Any idea why this is happening?
Thanks!
I have the same problem,
There is an open issue for this bug in github (https://github.com/remy/nodemon/issues/146).
With the -L, it work, but it take 3, 4 seconds to restart after a change.
nodemon -L server.js

Resources