Search code examples
node.jsibm-cloudwatson-conversationwatsonclfs

Bluemix Node js app push Start unsuccessful


I am using watson conversation service on node js application.

while trying to push application to 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

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.');

Solution

  • Your program might run locally. However, to run as Bluemix Node.js app on Cloud Foundry it needs to meet certain requirement. A web app is expected and the health manager checks on the expected port whether your app is alive. 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.

    As an alternative for your code, you could consider setting a health check type of 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.