【发布时间】:2019-01-11 01:16:24
【问题描述】:
所以我目前有一个 Nodejs 应用程序,它生成一个执行 java 应用程序的子进程,当直接从命令提示符运行时,它工作得很好。
http.createServer(function (request, response) {
console.log('Started Executing Request! \n' );
const { exec } = require('child_process');
exec('"C:\\Program Files\\Java\\jdk1.8.0_172\\bin\\java.exe" -jar "C:\\Temp\\myjava.jar"', (err, stdout, stderr) => {
if (err) {
console.log('There was an error! ' + err);
// node couldn't execute the command
return;
}
// the *entire* stdout and stderr (buffered)
console.log('stdout: ' + stdout);
console.log('stderr: ' + stderr);
});
console.log('Finished Executing Request! \n' );
}).listen(8087);
// Console will print the message
console.log('Server running at http://127.0.0.1:8087/ \n');
我遇到的问题是,当把它放到服务中时,它似乎不想执行 java 应用程序。我把它输出到一个日志文件,我确实有“开始执行请求”和“完成执行请求!”在日志中但没有执行java。
【问题讨论】:
标签: java node.js windows-services nssm