David Duman
David Duman

Reputation: 6656

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

Upvotes: 7

Views: 8394

Answers (4)

rainabba
rainabba

Reputation: 4267

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

Upvotes: 2

Josh C.
Josh C.

Reputation: 4363

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.

Upvotes: 2

balazs
balazs

Reputation: 5788

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

Upvotes: 9

Mulan
Mulan

Reputation: 135257

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

Upvotes: 4

Related Questions