I am facing error while creating a child_process via exec in nodejs. It was working fine under 0.12.x node version, only change is nodejs upgrade to 6.11.3.This error occurs 2 out of 10 times not able to find the reason and solution. Thanks in advance
Code details:
var exec = require('child_process').exec;
cmd = 'sh /home/ec2-user/bin/lldn start';
exec(cmd,{ shell: '/bin/bash'},
function (error, stdout, stderr) {
if (error) {
deferred.reject({
stdout: stdout,
stderr: stderr,
error: error,
cmd: cmd
});
} else {
deferred.resolve({
stdout: stdout,
stderr: stderr,
error: error,
cmd: cmd
});
}
});
Error details:
msg="{ Error: Command failed: sh /home/ec2-
user/logu/datanode/bin/lldn start
at ChildProcess.exithandler (child_process.js:198:12)
at emitTwo (events.js:106:13)
at ChildProcess.emit (events.js:191:7)
at maybeClose (internal/child_process.js:920:16)
at Process.ChildProcess._handle.onexit
(internal/child_process.js:230:5)
killed: false,
code: null,
signal: 'SIGHUP',
cmd: 'sh /home/ec2-user/logu/datanode/bin/lldn start' }"
I had the same problem with a different command and after some digging I realized that exec
is hiding the proper error.
I was able to show the real error adding a logger in the following place:
function (error, stdout, stderr) {
// Not all three vars are needed, but better to show more
console.log(error, stdout, stderr);
if (error) {
deferred.reject({
I know it's not the solution to your specific issue but I hope this helps.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.