Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to keep a node server app running on windows server

Tags:

node.js

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

like image 288
dvdmn Avatar asked Aug 22 '13 21:08

dvdmn


4 Answers

Run your script file, as a service, with nssm.

like image 122
balazs Avatar answered Sep 19 '22 22:09

balazs


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
like image 23
Mulan Avatar answered Sep 19 '22 22:09

Mulan


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.

like image 24
Josh C. Avatar answered Sep 19 '22 22:09

Josh C.


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).

like image 22
rainabba Avatar answered Sep 21 '22 22:09

rainabba