Log server start
This commit is contained in:
parent
a217db1945
commit
7f1b9a5d96
@ -7,7 +7,7 @@ var deviceManager: DeviceManager!
|
|||||||
|
|
||||||
private var provider: VaporMetricProvider!
|
private var provider: VaporMetricProvider!
|
||||||
|
|
||||||
private var asyncScheduler: AsyncScheduler = MultiThreadedEventLoopGroup(numberOfThreads: 2)
|
private var asyncScheduler = MultiThreadedEventLoopGroup(numberOfThreads: 2)
|
||||||
|
|
||||||
private let df: DateFormatter = {
|
private let df: DateFormatter = {
|
||||||
let df = DateFormatter()
|
let df = DateFormatter()
|
||||||
@ -57,6 +57,7 @@ public func configure(_ app: Application) throws {
|
|||||||
}
|
}
|
||||||
|
|
||||||
print("[\(df.string(from: Date()))] Server started")
|
print("[\(df.string(from: Date()))] Server started")
|
||||||
|
log("[\(df.string(from: Date()))] Server started")
|
||||||
|
|
||||||
// Gracefully shut down by closing potentially open socket
|
// Gracefully shut down by closing potentially open socket
|
||||||
// Must be done after app is running, otherwise error is thrown
|
// Must be done after app is running, otherwise error is thrown
|
||||||
@ -70,6 +71,10 @@ public func configure(_ app: Application) throws {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public func shutdown() {
|
||||||
|
try? asyncScheduler.syncShutdownGracefully()
|
||||||
|
}
|
||||||
|
|
||||||
private func loadKeys(at url: URL) throws -> (deviceKey: Data, remoteKey: Data) {
|
private func loadKeys(at url: URL) throws -> (deviceKey: Data, remoteKey: Data) {
|
||||||
let authContent: [Data] = try String(contentsOf: url)
|
let authContent: [Data] = try String(contentsOf: url)
|
||||||
.trimmingCharacters(in: .whitespacesAndNewlines)
|
.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||||
|
@ -4,7 +4,10 @@ import Vapor
|
|||||||
var env = Environment.production //.detect()
|
var env = Environment.production //.detect()
|
||||||
try LoggingSystem.bootstrap(from: &env)
|
try LoggingSystem.bootstrap(from: &env)
|
||||||
let app = Application(env)
|
let app = Application(env)
|
||||||
defer { app.shutdown() }
|
defer {
|
||||||
|
app.shutdown()
|
||||||
|
shutdown()
|
||||||
|
}
|
||||||
|
|
||||||
try configure(app)
|
try configure(app)
|
||||||
try app.run()
|
try app.run()
|
||||||
|
Loading…
Reference in New Issue
Block a user