running nodejs app on windows node-windws


Dealing with deploying nodejs application on the windows server we found that linux is much better option with vast and easy capabilities.

With all of other option below are the script which create windows service and run node js app on as server on windows.

Below are the script which create windows services and point out the script to run without any delay.

 

–Create windows Service

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: ‘D:\\mysolution\\src\\index.js’
});

// Listen for the “install” event, which indicates the
// process is available as a service.

svc.on(‘install’,function(){
svc.start();
});

svc.install();

 

—————— Below snippet is to remove the service.

 

var Service = require(‘node-windows’).Service;

// Create a new service object
var svc = new Service({
name:’Hello World’,
script: require(‘path’).join(__dirname,’src\\index.js’)
});

// 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();

 

In the end , my personal opinion is linux is best option when dealing with nodej applications.

 

 

 

#sharingiscaring #helpmeinfuture #offcourse

 

Reference :https://github.com/coreybutler/node-windows

 

Leave a comment