Node App Run Forever? - node.js

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

Related

How to stop and start node.js and update app.js?

I am trying to set up a node.js server. On my Mac, I can start and stop the app in terminal like:
start=
node app.js
stop=
CTR-c
I also have the same node setup on my linux server website.
I try to do the same start and stop in the terminal the same way on the linux server but I can't seem to stop it with CTR-c even though it looks like it did work.
The app keeps running.
My goal is to to be able to make edits / mods to the webserver node app. I think we have to stop and start to update the changes - but it does not seem to be working.
I know a bit about nodemon - but do not know if it should be used on live production servers?
Q: How do I make changes to the linux server app and get them to show up like they do in MacOS?

pm2 is not working in amazon ec2 with node application

I have node application hosted in amazon ec2.
I used nginx to point it in my domain.
It runs perfectly when i use npm start to run the application.
But when i use pm2, it doesnt work.
pm2 list command shows that the app is running.
But url doesn't work. Even when i again run npm start app gets started that clearly states that the port is free. So pm2 is not actually running anything on that port. But pm2 says app is online.
I was running the wrong file from pm2. As it was express project, so i had to run bin/www
So the following command solve the issue:
pm2 start bin/www
Answered it here as well:
https://github.com/Unitech/pm2/issues/3252
Thanks

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

Node.js deployment to production in windows server

I'm fairly new with node.js platform.
I'm working on deploying a node.js app to production in windows sever.
Currently I'm using forever for my production server, and pm2 for development server(just to see how different process managers work.)
What I noticed is my app is down after a while (normally couple days).
I think it might be because my user session which runs the process is closed.
Can you share with me the "correct" deployment steps?
The steps I take to deploy are:
1. Run node cmd as administrator
2. Go to site root
3. Run forever start server.js or pm2 start server.js
Thanks in advance.

how to keep a node server app running on windows server

I'm working on a project and I have modified node.js' 'simple chat room' sample application for my need, it works fine.
I have to call the server app's url (the .js file) to start it before opening the client page in the browser, so far everything works fine. But if the node server app goes down for any reason (server restart, iis restart, etc), the client page returns an error .
My question is, how can I keep the node server app alive all the time even after it interrupted. How can I do that without having a monitor or a script which runs every x minutes.
I'm using IIS 7.5 and iisnode module.
Thanks
Run your script file, as a service, with nssm.
Pretty sure you'll want jesus
Installation
$ npm install -g jesus
Usage
Start monitoring server
$ jesus daemon /path/to/server.log
To start a process
$ jesus start <id> node /path/to/my-app/index.js
To stop one
$ jesus stop <id>
To stop all
$ jesus stopall
I'm not sure about running node in iis. However, you can take a look at the node packages forever, pm2, and nodemon, which will recover the instance in case of failure.
Here's how to install node.js as a service
Here's something on installing node in iis 7.5
Just an update.
I've been using iisnode at work for the better part of a year. I would recommend it if you are deploying to Windows.
https://github.com/isaacs/node-supervisor and https://github.com/remy/nodemon have slightly different feature sets, but aren't Windows specific and still work on Windows unlike many of the other more popular, yet incomplete options such as forever and eternity (as of today anyway).

Resources