我正在运行Windows 10,我想从forever
(v3.0.0)执行Windows .bat脚本
forever
已在全球范围内安装且运行良好,并且我已成功用于启动其他应用程序。
在这种情况下,我使用的forever
JSON配置文件如下:
{
"uid": "MyApp","command": "cmd.exe","script": ["/c",".\\scripts\\init-myApp.bat"],"sourceDir": "C:\\myApp","logFile": "C:\\myApp\\forever.log","outFile": "C:\\myApp\\out.log","errFile": "C:\\myApp\\error.log","append": true
}
基于以下事实,这似乎是正确的:
- this answer that shows how to execute a .bat file with
spawn
-
forever
正在幕后呼叫child_process.spawn
- 那个
forever-monitor
checks ifscript
is an array and splits it in a way that should work
但是当我尝试运行此代码时,我收到验证器错误:
internal/validators.js:120
throw new ERR_INVALID_ARG_TYPE(name,'string',value);
^
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received an instance of Array
at validateString (internal/validators.js:120:11)
at Object.join (path.js:375:7)
因为forever/cli.js
calls path.join
on the script option before passing it along to forever-monitor
我也尝试过以下组合:
{
"uid": "MyApp","script": ".\\scripts\\init-myApp.bat",...
}
仅启动cmd
而不执行批处理文件,并且
{
"uid": "MyApp","command": ["cmd.exe","/c"],...
}
在forever-monitor
中引发错误,因为它假定command
是字符串,而不是数组。
有什么方法可以传递必要的/c
参数,还是可以使用forever
执行批处理脚本?