This is not at all what you need to configure in node.js, it is purely OS responsibility (Windows in your case). The most reliable way to achieve this is through the Windows service.
In this super-lightweight module that installs node script as a Windows service, it is called node-windows ( npm , github ,. I used this before and worked like a charm.
var Service = require('node-windows').Service; // Create a new service object var svc = new Service({ name:'Hello World', description: 'The nodejs.org example web server.', script: 'C:\\path\\to\\helloworld.js' }); // Listen for the "install" event, which indicates the // process is available as a service. svc.on('install',function(){ svc.start(); }); svc.install();
ps
I found the thing so useful that I built an even more convenient wrapper around it ( npm , github ).
Installation:
npm install -g qckwinsvc
Service Installation:
> qckwinsvc prompt: Service name: [name for your service] prompt: Service description: [description for it] prompt: Node script path: [path of your node script] Service installed
Removing a service:
> qckwinsvc --uninstall prompt: Service name: [name of your service] prompt: Node script path: [path of your node script] Service stopped Service uninstalled
talles Dec 22 '13 at 0:06 2013-12-22 00:06
source share