Repository navigation
Expand file tree
/
Copy pathApp.swift
More file actions
48 lines (41 loc) · 1.74 KB
/
Copy pathApp.swift
File metadata and controls
48 lines (41 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
//===----------------------------------------------------------------------===//
//
// This source file is part of the SwiftConfiguration open source project
//
// Copyright (c) 2026 Apple Inc. and the SwiftConfiguration project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of SwiftConfiguration project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
import Configuration
import Hummingbird
import Logging
@main
struct App {
static func main() async throws {
// Application will read configuration from the following in the order listed
// Command line, Environment variables, dotEnv file, defaults provided in memory
// CLI >overrides> ENV >overrides> .env >overrides> in-memory defaults
async let staticProviders: [(any ConfigProvider)] = [
CommandLineArgumentsProvider(),
EnvironmentVariablesProvider(),
EnvironmentVariablesProvider(environmentFilePath: ".env", allowMissing: true),
InMemoryProvider(values: [
// default log level
"log.level": "info",
// the default, expected dynamic configuration location
"config.filePath": "/etc/config/appsettings.yaml",
// default reload interval is 15 seconds, set to 1 second for the example
"config.pollIntervalSeconds": 1,
//name used in the logger
"http.serverName": "config-reload-example",
]),
]
let app = try await buildApplication(initialConfigProviders: staticProviders)
try await app.runService()
}
}