diff --git a/Sources/App/configure.swift b/Sources/App/configure.swift index d942de2..aec29f8 100755 --- a/Sources/App/configure.swift +++ b/Sources/App/configure.swift @@ -23,9 +23,7 @@ private let dateFormatter: DateFormatter = { public func configure(_ app: Application) async throws { let storageFolder = URL(fileURLWithPath: app.directory.resourcesDirectory) let logFolder = storageFolder.appendingPathComponent("logs") - try migrate(folder: logFolder) - fatalError("Done") - + let monitor = MetricObserver(logFileFolder: logFolder, logMetricId: "sesame.log") MetricObserver.standard = monitor @@ -91,7 +89,7 @@ func log(_ message: String) { import CBORCoding -private func migrate(folder: URL) throws { +public func migrate(folder: URL) throws { try migrateMetric("sesame.log", containing: String.self, in: folder) try migrateMetric("sesame.status", containing: ServerStatus.self, in: folder) try migrateMetric("sesame.connected", containing: Bool.self, in: folder) diff --git a/Sources/Run/main.swift b/Sources/Run/main.swift index 4e625fb..367829a 100644 --- a/Sources/Run/main.swift +++ b/Sources/Run/main.swift @@ -6,6 +6,12 @@ try LoggingSystem.bootstrap(from: &env) let app = Application(env) defer { app.shutdown() } +let storageFolder = URL(fileURLWithPath: app.directory.resourcesDirectory) +let logFolder = storageFolder.appendingPathComponent("logs") +print("Starting migration") +try migrate(folder: logFolder) +print("Finished migration") +/* private let semaphore = DispatchSemaphore(value: 0) Task { try await configure(app) @@ -13,3 +19,4 @@ Task { } semaphore.wait() try app.run() +*/