简体   繁体   English

Bluemix Node js应用程序推送启动失败

[英]Bluemix Node js app push Start unsuccessful

I am using watson conversation service on node js application. 我在节点js应用程序上使用watson对话服务。

while trying to push application to bluemix. 同时尝试将应用程序推送到bluemix。 (through command prompt) After uploading all the files.. (通过命令提示符)上传所有文件之后。

0 of 1 instance running, 1 starting 0 of 1 instance running, 1 starting 0 of 1 instance running, 1 starting 0 of 1 instance running, 1 starting 0 of 1 instance running, 1 crashed FAILED 1个实例中的0个正在运行,1个实例中的0个正在开始运行,1个实例中的0个正在开始运行,1个实例中的0个正在开始运行,1个实例中的0个正在开始运行,1个实例中的0个开始正在运行,1个已崩溃FAILED

Start unsuccessful 开始失败

Kindly help what's the issue.. 请帮助解决问题。

command prompt 命令提示符

'My coding '我的编码

var watson=require('watson-developer-cloud');

var conversation =watson.conversation({
  url: 'https://gateway.watsonplatform.net/conversation/api',
  username:' ',
  password:' ',
  version:'v1',
  version_date:'2017-06-20'
});
var context={};
context.hour=-1;
function prompt(question,callback){
  var stdin=process.stdin,
  stdout=process.stdout;
  stdin.resume();
  stdout.write(question);
  stdin.once('data',function(data){
    callback(data.toString().trim());
  });
}

function tConvert(time){
  time=time.toString().match(/^([01]\d2[0-3])(:)([0-5]\d)(:[0-5]\d)?$/)||[time];

  if(time.length>1){
    time=time.slice(1);
    time[5]=+time[0]<12?'AM':'PM';
    time[0]=+time[0]%12||12;
  }
  return time.join('');
}
function convMessage(message){
    var d=new Date();
  var n=tConvert(d.getHours() + ':' + d.getMinutes() + ':00');
  context.hour=(n.split(':'))[0];
  context.minute=(n.split(':'))[1];
  conversation.message({
    workspace_id:'09ee7558-0d3e-4af3-8429-14e60be348d7',
    input:{'text':message},
    context:context
  },function(err,response){
      if(err){
        console.log('error:',err);
      }else {
          console.log('Watson: ' + response.output.text[0])
          prompt('You: ', function(input){
            convMessage(input);
          });
          context=response.context;
        }
      });
    }
convMessage('Hi.');

Your program might run locally. 您的程序可能在本地运行。 However, to run as Bluemix Node.js app on Cloud Foundry it needs to meet certain requirement. 但是,要在Cloud Foundry上作为Bluemix Node.js应用程序运行,它需要满足某些要求。 A web app is expected and the health manager checks on the expected port whether your app is alive. 预期会出现一个Web应用程序,而运行状况管理器会在预期的端口上检查您的应用程序是否仍在运行。 If the app cannot be detected it is considered "dead" and the logs will show it as "crashed". 如果无法检测到该应用程序,则将其视为“已死”,并且日志会将其显示为“崩溃”。

Take a look at the sample app " Conversation Simple " and the main file "server.js" for how the port info is handled. 查看示例应用程序“ Conversation Simple ”和主文件“ server.js” ,了解如何处理端口信息。

As an alternative for your code, you could consider setting a health check type of process . 作为代码的替代方法,您可以考虑设置process健康检查类型 It would indicate Bluemix / Cloud Foundry that you don't deploy a regular (Web) app, but something running in the background or executed once. 这将表明Bluemix / Cloud Foundry您没有部署常规(Web)应用程序,而是某些在后台运行或执行一次。

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

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