Tuesday, October 16, 2012

Node.js Applications as a Windows Service

Normally I try not to repost stories, but this came in so handy that I have to share it.

I was working on a getting Node.js to play nice with MongoDB. This is my first time working with Mongo so I cloned MongoClikker in an effort to bring a little gui to this text-based party. I eventually realized I wanted MongoClikker to be running at all times on my dev box (which is running Windows). Rather than having a command prompt at all times, I was able to use the instructions on Tatham Oddie's post to make MongoClikker run as a service thanks to the help of NSSM.

I was able to make this work using the following commands:

nssm.exe install mongoclikker "C:\Program Files\nodejs\node.exe" "C:\code\mongoclikker\app.js"
net start mongoclikker

So far it is working wonders!