OpenShift: “Failed to execute control start” on node application

后端 未结 2 608
清歌不尽
清歌不尽 2020-12-03 11:52

I realize in advance this is kind of a vague question, but I\'m stumped as to what else I can try here...

I\'ve been going through other SO questions and following t

相关标签:
2条回答
  • 2020-12-03 12:21

    OpenShift Node apps require you to give the configuration to start your app in package.json under main and scripts.start:

    "scripts": {
         "start": "node server.js"
      },
    "main": "server.js"
    

    Further it also requires to give it IP and PORT provided by your node environment through environment variables:

    for PORT Number       process.env.OPENSHIFT_NODEJS_PORT
    for IP                process.env.OPENSHIFT_NODEJS_IP
    

    If these variables not used in app , it shows error which looks like:

    Waiting for application port (8080) become available ...
    Application 'appname' failed to start (port 8080 not available)
    

    Here is an example to show how to use these environment variables in your node app(from source):

    var server_port = process.env.OPENSHIFT_NODEJS_PORT || 8080
    var server_ip_address = process.env.OPENSHIFT_NODEJS_IP || '127.0.0.1'
    
    server.listen(server_port, server_ip_address, function () {
    console.log( "Listening on " + server_ip_address + ", server_port " + port )
    });
    

    Source: https://blog.openshift.com/run-your-nodejs-projects-on-openshift-in-two-simple-steps/

    Related Post: Application 'appname' failed to start (port 8080 not available) on open shift node app

    0 讨论(0)
  • 2020-12-03 12:45

    For an OpenShift Node app you need to specify the start script as: main: "server.js" instead of using scripts. This is due to the way Node applications are started on OpenShift using node-supervisor.

    0 讨论(0)
提交回复
热议问题