我正在使用node-windows将我的节点应用程序作为服务运行。因为我打算使用node-expose-sspi,所以我使用 powershell 创建了一个服务帐户(我检查了 Test-ADServiceAccount)。
如果我运行此代码
var Service = require('node-windows').Service;
// Create a new service object
var svc = new Service({
name:'project-name',
description: 'node server',
script: 'C:\\server\\server.js'
, allowServiceLogon: true
// ,
// 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();
});
// 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!\nVisit http://127.0.0.1:5000 to see it in action.');
});
// Install the script as a service.
svc.install();
我得到控制台日志“项目名称已启动...”但未创建服务(我检查了 get-process)。如果我省略 'allowServiceLogon: true' 则创建服务。
如何在节点窗口中指定服务帐户?