简体   繁体   English

无法在Amazon EC2实例上运行Node.js child_process

[英]unable to run nodejs child_process on amazon ec2 instance

I am running nodejs child_process function spawn() to do mongoexport. 我正在运行nodejs child_process函数spawn()进行mongoexport。 I have passed all the necessary fields to the command and it is working fine on my local machine. 我已经将所有必需的字段传递给命令,并且在我的本地计算机上运行良好。 Below is the function code 下面是功能代码

userDetailsChild = spawn('mongoexport', ['--username',username,'--
password',password,'--db',db,'--collection','users','--type', 'csv', 
'--fields', 'userId,firstName','--
out','/home/bitnami/apps/webapp/dist/server/prod/public/user-
details.csv']);

userDetailsChild.on('exit', function (code: any) {
  if (code != 0) {
    userDetailsChild.kill();
    callback(new Error(), null);
  } else {
    console.log('userDetailsChild process closed with code ' + code);
    userDetailsChild.kill();
  }
});

When I try to run the same code with server credentials on amazon WordPress ec2 instance on my server machine it fails with no error message. 当我尝试在服务器计算机上的Amazon WordPress ec2实例上使用服务器凭据运行相同的代码时,它将失败,并且没有错误消息。 Somewhere I have seen path variables set as process.env['PATH'] = process.env['PATH'] + ':' + process.env['LAMBDA_TASK_ROOT']; 我在某个地方看到路径变量设置为process.env ['PATH'] = process.env ['PATH'] +':'+ process.env ['LAMBDA_TASK_ROOT']; But didnt worked in my case. 但没有在我的情况下工作。 Any help will be appreciated!! 任何帮助将不胜感激!!

While I do not know why the command is failing, I do know that you appear to be ignoring the more than likely helpful information coming back to you via stderr. 虽然我不知道命令为什么失败,但是我确实知道您似乎忽略了更多可能通过stderr返回给您的有用信息。 ;) ;)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM