windows-service - Run Node.JS programs as native Windows Services.

2,486 views
Skip to first unread message

Stephen Vickers

unread,
Feb 21, 2013, 5:41:07 PM2/21/13
to nod...@googlegroups.com
Hi All,

I've created a new module named "windows-service" providing the ability to run Node.JS programs as native Windows Services.

The new module can be installed using npm:


Steve

Jeremy Darling

unread,
Feb 21, 2013, 10:06:14 PM2/21/13
to nodejs
What is the difference in this and WinSer using NSSM?  I'm not picking I'm just curious.


--
--
Job Board: http://jobs.nodejs.org/
Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nod...@googlegroups.com
To unsubscribe from this group, send email to
nodejs+un...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en
 
---
You received this message because you are subscribed to the Google Groups "nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

José F. Romaniello

unread,
Feb 22, 2013, 6:01:16 AM2/22/13
to nod...@googlegroups.com

Windows-service looks very nice, well done!

Jeremy: winser is a wrapper around nssm with some friendly defaults for node.js. It will install the application as a service and it will run it with "npm start". Some PROs I see in winser/nssm:

  • nssm in my opinion has more time around and it has an special behavior for exits. See Service shutdown, Actions on exit and Restart throttling in this link.
  • winser doesn't need python, Visual Express, etc in order to install. Stephen you can workaround this with a fallback to a prebuilt binary in your package, please have a look to my windows event log package, it try to build but if the build fail it will use a prebuilt version.
  • when running the application with winser the current working directory is the place where you have the package.json file, no need to change that

Pros I see in windows-service

  • an api to define services inside node. The examples shown in the readme are very good and if you think about it there are a lot of things that work in that way, (with --install, etc)
  • no extra dependencies, since it is all done in c

 


2013/2/22 Jeremy Darling <jeremy....@gmail.com>

Stephen Vickers

unread,
Feb 22, 2013, 7:17:56 AM2/22/13
to nod...@googlegroups.com
Hi Jeremy,

A number of small reasons why I would use windows-service instead (some people may consider some of these points moot, I don't):
  • Node.js and program path detection is automatic and obvious
  • Supports spaces in service names (although this could be fixed quite easily in WinSer)
  • Doesn't depend on npm to add, remove and run services
  • Doesn't depend on nssm.exe which means one less task of trying to keep that up to date (not assuming the module author will always want to update nssm.exe to the latest version when available)
    • Which also may have library dependency issues - unless you compile it yourself
Then there a couple of major reasons, which are probably more in-line with my requirements.

I've already written something similar for Perl, for the company I work for, but have never been allowed to make that code public.

I'm just getting into Node.js with the view of writing an application delivered using a Windows installer (NSIS based) as the end systems will have no build environment available.

So, in part this was a learning exercise to see if it was possible, and to remove dependency on npm for a deployed application.

It's also worth considering that the service code base is much smaller than the nssm.exe code base, and this is not a criticism of nssm.exe (quite the opposite, it seems like a very good program), the point is that there is less to go wrong and maintain.

Steve

Stephen Vickers

unread,
Feb 22, 2013, 8:07:06 AM2/22/13
to nod...@googlegroups.com
I should also add, I don't want to appear to be critical of WinSer, or nssm.exe for that matter.  It's just that I have my own motivations,  requirements and preferences, as do the authors of those programs.

José F. Romaniello

unread,
Feb 22, 2013, 8:17:22 AM2/22/13
to nod...@googlegroups.com
Sure thing Stephen! I am the author of winser and I gave my point of view on your project and as I said it looks very nice, I will consider next time i have to deploy something to a windows server.

for me node.js is about alternatives, so i am really glad winser is not the only option to run node programs as windows services now

regards


2013/2/22 Stephen Vickers <vortex...@gmail.com>

Jeremy Darling

unread,
Feb 22, 2013, 9:40:30 AM2/22/13
to nodejs
Stephen, no offense taken at all.  As for WinSer, its what we use today in our production environment without NPM, so that is a bit of a misnomer.  Simply place it in a Vendor folder and away you go.

I'll be looking at Windows-Service as well.

Would be nice if it were on GitHub though :)

 - Jeremy

Stephen Vickers

unread,
Feb 23, 2013, 4:44:11 PM2/23/13
to nod...@googlegroups.com
Heh, perhaps that's a cue to introduce myself to git :)
Reply all
Reply to author
Forward
0 new messages