我有jboss服务器和nodejs客户端。我的工作是将nodejs client.js连接到jboss server.i我正在使用jboss服务器作为窗口服务。到现在为止我必须在命令提示符下运行manualy命令 node client.js连接jboss server.now我想创建nodejs client.js作为窗口服务。为此,我使用node-windows模块创建了nodeservice.js。 nodeservice.js中的代码如下:
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();
此代码帮助我创建窗口服务,我的服务名称是nodeservice。
然后我转到组件服务 - >服务并单击nodeservice,给定启动类型“自动”并单击启动服务的启动按钮。但是在2-3秒后节点服务服务停止。
我的问题是我为nodejs客户端名称nodeservice创建的窗口服务已创建但是当我在组件服务中启动服务时它会在2-3秒后停止
表示我的窗口服务名称nodeservice不是属性创建的。可能是我做错了什么
我没有找到解决为什么nodeservice在2-3秒后停止的正确途径。