我想作为服务运行的脚本需要'start‘作为参数。
如何使用node-windows设置参数
下面是来自project页面的设置js脚本:
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: 'C:\\path\\to\\wiki.js',
nodeOptions: [
'--harmony',
'--max_old_space_size=4096'
]
});
// Listen for the "install" event, which indicates the
// process is available as a service.
svc.on('install',function(){
svc.start();
});
svc.install();将脚本值设置为'wiki start‘会导致错误,因为模块会将其视为文件。日志如下:
Starting C:\Program Files\nodejs\node.exe --harmony --max_old_space_size=4096 C:\Users\<me>\AppData\Roaming\npm\node_modules\node-windows\lib\wrapper.js --file ..\wiki.js --log "wiki.js wrapper" --grow 0.25 --wait 1 --maxrestarts 3 --abortonerror n --stopparentfirst undefined "-- start"我也尝试发送nodeOptions,将'-- start‘添加到数组中,但模块将其作为字符串添加到命令行中,即"-- start“。
发布于 2020-05-28 06:24:17
这就是scriptOptions参数的用途。它是在node-windows@0.1.11中引入的
var svc = new Service({
name:'Hello World',
description: 'The nodejs.org example web server.',
script: 'C:\\path\\to\\wiki.js',
scriptOptions: 'start'
});https://stackoverflow.com/questions/52953616
复制相似问题