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.
Asked
Active
Viewed 127 times
1

Amith Shaju
- 143
- 7
1 Answers
1
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.

Robert F. Dickerson
- 473
- 3
- 16
-
I had actually referred to your tutorial https://www.youtube.com/watch?v=xEStdmwFVBg to setup my local Kitura as I wanted to start from the basics. I am pretty new to Swift Kitura so could u direct me to a tutorial which implements CloudFoundryEnv? – Amith Shaju Nov 20 '16 at 02:24
-
1Oh excellent, glad my tutorial is helpful. I think this package is pretty well documented, [Swift-cfenv](https://github.com/IBM-Swift/Swift-cfenv) if you want to take a look at that. Take a look at some of our examples, like [TodoList](https://github.com/IBM-Swift/TodoList-CouchDB/) and make sure you have a manifest.yml and a Procfile as seen there. – Robert F. Dickerson Nov 20 '16 at 03:20
-
Adding CloudFoundryEnv fixed the issue. Thanks a lot. – Amith Shaju Nov 21 '16 at 16:35