我的程序似乎在 Heroku 上运行良好,但是在重新加载页面 3-4 次后,它崩溃了,我得到了错误H13: Connection closed without response
。但是,当我在计算机上运行它时,它工作得非常好并且没有任何错误。
这是我的代码:
#if os(Linux)
import Glibc
#else
import Darwin
#endif
import Vapor
let arrayA: [String] = ["some strings here"]
let arrayB: [String] = ["more strings there"]
let arrayC: [String] = ["and some more here"]
func buildName (from arrayA: [String], and arrayB: [String], and arrayC: [String]) -> String {
#if os(Linux)
let a: Int = Int(random() % (arrayA.count + 1))
let b: Int = Int(random() % (arrayB.count + 1))
let c: Int = Int(random() % (arrayC.count + 1))
#else
let a: Int = Int(arc4random_uniform(UInt32(arrayA.count)))
let b: Int = Int(arc4random_uniform(UInt32(arrayB.count)))
let c: Int = Int(arc4random_uniform(UInt32(arrayC.count)))
#endif
return (arrayA[a] + " " + arrayB[b] + " " + arrayC[c])
}
let defaultHead: String = "<head><meta charset='utf-8'></head>"
//create Droplet object
let drop = Droplet()
// REGISTER Routes and handlers
drop.get { req in
return buildName(from: arrayA, and: arrayB, and: arrayC)
}
// Start the server
drop.run()
我究竟做错了什么?