2016-11-19 66 views

回答

1

由於我看不到您的源代碼,因此很難說清楚。但可能是因爲您沒有聽Bluemix分配給您的端口。

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!") 
} 

會發生什麼事是,雖然它工作正常,以便時刻聆聽8090(例如)在本地運行時,Bluemix將分配一個端口,你可以監聽和端口轉發器將流量從443到分配的端口。部署過程中的Bluemix將檢查端口上是否有監聽的內容,如果此健康檢查失敗,則會假定部署失敗。

+0

我實際上已經提到你的教程https://www.youtube.com/watch?v=xEStdmwFVBg來設置我的本地Kitura,因爲我想從基礎開始。我對Swift Kitura很新,所以你可以指導我實現CloudFoundryEnv的教程嗎? –

+1

哦,非常好,很高興我的教程很有幫助。我認爲這個軟件包有很好的文檔記錄,如果你想看看這個,[Swift-cfenv](https://github.com/IBM-Swift/Swift-cfenv)。看看我們的一些例子,比如[TodoList](https://github.com/IBM-Swift/TodoList-CouchDB/),確保你有一個manifest.yml和一個Procfile。 –

+0

添加CloudFoundryEnv修復了這個問題。非常感謝。 –