Search code examples
swiftibm-cloudkitura

Kitura failed to deploy to bluemix


I created a local swift kitura app which works fine locally. But when I push it to bluemix the instance starts running and then fails. enter image description here


Solution

  • It's hard to tell exactly since I can't see your source code. But it might be because you are not listening to the port that Bluemix assigns to you.

    do {
    let port = try CloudFoundryEnv.getAppEnv().port
    Log.verbose("Assigned port is \(port)")
    
    Kitura.addHTTPServer(onPort: port, with: controller.router)
    Kitura.run()
    
    
    } catch CloudFoundryEnvError.InvalidValue {
        Log.error("Oops... something went wrong. Server did not start!")
    }
    

    What happens is that although it works fine to always listen to 8090 (for example) when running locally, Bluemix will assign a port for you to be listening on and the port forwarder will direct traffic from 443 to that assigned port. Bluemix during deploy will check to see if something is listening on the port, and if it fails this health check, it will be assumed the deploy failed.