I created a simple http server in Node.js.
I wanted to make it run permanently on my Windows 2008 machine, so that, if the computer reboots, it automatically restarts.>
Use this one, really simple https://github.com/coreybutler/node-windows
Create two js file on your project. And run those as
node your_service.js node your_service_remove.js
For install:
/**
* Created by sabbir on 08/18/2015.
*/
//ref: https://github.com/coreybutler/node-windows
var Service = require('node-windows').Service;
// Create a new service object
var svc = new Service({
name:'nodeDemoApp',
description: 'The nodejs.org example web server.',
script: 'D:\\NodeJS\\demoWeb\\bin\\www'
});
// Listen for the "install" event, which indicates the
// process is available as a service.
svc.on('install',function(){
svc.start();
});
svc.install();
For uninstall:
var Service = require('node-windows').Service;
// Create a new service object
var svc = new Service({
name:'nodeDemoApp',
script: require('path').join(__dirname,'bin\\www')
});
// Listen for the "uninstall" event so we know when it's done.
svc.on('uninstall',function(){
console.log('Uninstall complete.');
console.log('The service exists: ',svc.exists);
});
// Uninstall the service.
svc.uninstall();