7

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

dvdmn
  • 6,456
  • 7
  • 44
  • 52

4 Answers4

9

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

balazs
  • 5,698
  • 7
  • 37
  • 45
  • Interesting option. I'm upvoting as a general solution, but I recommend my answer below for Node so that no part of the app or it's environment becomes platform specific. – rainabba Sep 10 '14 at 02:35
  • The question was platform specific, and by the way you still need to start nodemon, and supervisor if you restart your machine, while using nssm, it's automatically up and running on a restart, however for development, I use nodemon too :) – balazs Sep 10 '14 at 10:05
4

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
Mulan
  • 129,518
  • 31
  • 228
  • 259
2

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.

Community
  • 1
  • 1
Josh C.
  • 4,303
  • 5
  • 30
  • 51
  • forever doesn't work in Windows as of now without some special considerations (which I'm yet to discover) – rainabba Sep 10 '14 at 02:26
  • I have put a lot of time into iisnode and finally gave up. Also, I run on both platforms so it wouldn't be a solve-all. See my answer below for my present solution(s). – rainabba Sep 11 '14 at 06:39
2

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

rainabba
  • 3,804
  • 35
  • 35