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
Related
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
I have a new meteor application, and have a few tests that inserts data into a mongo collection, but no UI for that yet.
I have started a mocha test runner with meteor test --driver-package practicalmeteor:mocha. If I try to start a mongo console with meteor mongo I get this error.
mongo: Meteor isn't running a local MongoDB server.
This command only works while Meteor is running your application
locally. Start your application first with 'meteor' and then run this
command in a new terminal. This error will also occur if you asked
Meteor to use a different MongoDB server with $MONGO_URL when you ran
your application.
If you're trying to connect to the database of an app you deployed
with 'meteor deploy', specify your site's name as an argument to this
command.
How can I connect to the mongo to see which documents have been created by the tests?
When in 'test-mode', Meteor creates a dummy test-database to avoid overwriting data during testing.
This dB runs on port 3001 by default, but you cannot connect to it using meteor mongo ( you cannot specify the port )
If you have a real mongodb instance installed ( not the meteor built-in one), you can connect using:
mongo meteor --port 3001
It looks like your environment variable problem.
export MONGO_URL=''
meteor mongo
You can also try if there is some permission issues :
sudo meteor mongo
I'm pretty new to Docker, so I'm trying to take a node web app that I've written and Docker-ize it. The app is open source, so you can find it and the Dockerfile here: Paw-Wars
So you don't have to click through, the Dockerfile is here:
FROM mhart/alpine-node
WORKDIR /src
ADD . .
RUN npm install
EXPOSE 5050
COPY config.json /src/config.json
CMD npm run docker
So I open up the Docker Quickstart Terminal (I'm on Mac OS X), go to my path, and build it:
docker build -t paw-wars .
After it builds, I run it:
docker run paw-wars
And it spins up just fine and says it's listening on port 5050. I get the ip from docker-machine ip default, and try to connect to it on port 5050, but I get connection refused. Most searches I've done trying to solve this tell me that I need to make sure to use the correct IP, but I'm almost positive I'm doing that. Not really sure what I'm doing wrong. It's not in the repo, but I've also tried binding to 0.0.0.0 in my app (index.js), but that didn't work either.
Thanks!
The issue is that you MUST specify a port in your docker run command. I thought that using EXPOSE in your dockerfile is sufficient, but it's not. That's just to get the port exposed internally.
docker run -p 5050:5050 paw-wars worked great.
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.
I have 2 or more node app. That have to run forever if i reboot my PC that i don't want to start server it's automatic start for all node app.I used /ect/init.d node-app file and made some changes it's work but only for one node app but I have to many app on 1 server. Please any on help me.
Here is what you need to do this:
https://github.com/nodejitsu/forever