0

我正在Node.js中构建一个应用程序。该应用程序运行一个包含 python 脚本的子进程。我将我的应用程序部署在显示502-Bad Gateway (ngix) 的 gcloud。帮助将不胜感激。

这是我的代码..

app.post('/webhook/', function (req, res) {
 responseMessage("hi").then(function(msg){
    console.log("msg ==>", msg);
    res.send({response:msg});
    // res.sendStatus(200)
 });
})

function responseMessage(message){
  var spawn = require('child_process').spawn;
  var py    = spawn('python3.6', ['suman.py']),
  data = "suman",
  dataString = 's';
  data=message;
  py.stdout.setEncoding('utf8');
  return new Promise(function(resolve, reject){
        if(data){
                py.stdout.on('data', function(data){
                        dataString = data;
                        console.log('data', data);
                        resolve(data);
                });
                py.stdout.on('end', function(){
                  console.log('lets c',dataString);
                         resolve(dataString);
                });
                py.stdin.write(JSON.stringify(data));
                py.stdin.end();
                // res.end();
              } else {
                     reject({message: 'input shouldnt be null' })
             }
       });

     }

服务器错误 502 网关错误

502错误的网关

nginx

4

0 回答 0