0

i have jboss server and nodejs client .my work is to connect nodejs client.js to jboss server.i am using jboss server as window service. till now i had to run manualy command in command prompt
node client.js to connect jboss server.now i want to create nodejs client.js as window service. for this i have created nodeservice.js using node-windows module . the code within nodeservice.js are given below:

 var Service = require('node-windows').Service;

 // Create a new service object

 var svc = new Service({
name:'nodeservice',
description: 'The nodejs.org example web server.',
script: 'path\client.js',
env:{
name: "NODE_ENV",
value: "production"
}
});

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

 svc.on('install',function(){
 svc.start();
 console.log('install complete.');
 });

// Just in case this file is run twice.

svc.on('alreadyinstalled',function(){
console.log('This service is already installed.');
});

// Listen for the "start" event and let us know when the

// process has actually started working.
 svc.on('start',function(){
 console.log(svc.name+' started!.');
 });

 svc.on('error',function(){
 console.log('Something went wrong.');
  });

 svc.on('invalidinstallation ',function(){
 console.log(' This service is detected but missing require files');
  });

  // Install the script as a service.

  svc.install();

this code helps me to create window services and my service name is nodeservice .

then i went to component services->services and click nodeservice ,given startup type "Automatic" and click start button for start service. but after 2-3 second nodeservice service are stopped.

my problem is the window service which i have created for nodejs client name nodeservice are created but when i start the service in component services it stop after 2-3 second

means my window service name nodeservice are not created propertly. may be i am doing something wrong

i am not getting the right path to solve that why nodeservice is stop after 2-3 second .

saurabh
  • 31
  • 5
  • can anyone give answer – saurabh Dec 30 '14 at 08:11
  • are you sure it isn't breaking on console.log() within your actual application (not the install script)? As a windows service, console might be null, hence an exception is thrown – Gavin van Gent Jan 26 '15 at 12:16
  • In other words, your application is going to need to log everything to the EventViewer (https://github.com/coreybutler/node-windows#event-logging) rather than the console, from there you might actually be able to see some other issues you may have – Gavin van Gent Jan 26 '15 at 12:19

0 Answers0