Allow custom data directory
This commit is contained in:
parent
1c57b538be
commit
400753a9a2
@ -3,6 +3,7 @@
|
|||||||
"maxBodySize" : "2mb",
|
"maxBodySize" : "2mb",
|
||||||
"logPath": "\/var\/log\/caps/metrics",
|
"logPath": "\/var\/log\/caps/metrics",
|
||||||
"serveFiles": true,
|
"serveFiles": true,
|
||||||
|
"dataDirectory" : "/ch/data/caps",
|
||||||
"writers" : [
|
"writers" : [
|
||||||
"auth_key_1"
|
"auth_key_1"
|
||||||
]
|
]
|
||||||
|
@ -20,6 +20,15 @@ struct Config: Codable {
|
|||||||
/// Authentication tokens for remotes allowed to write
|
/// Authentication tokens for remotes allowed to write
|
||||||
let writers: [String]
|
let writers: [String]
|
||||||
|
|
||||||
|
let dataDirectory: String?
|
||||||
|
|
||||||
|
func customDataDirectory(or publicDirectory: String) -> URL {
|
||||||
|
guard let dataDirectory else {
|
||||||
|
return URL(fileURLWithPath: publicDirectory)
|
||||||
|
}
|
||||||
|
return URL(fileURLWithPath: dataDirectory)
|
||||||
|
}
|
||||||
|
|
||||||
func logURL(possiblyRelativeTo resourcesDirectory: URL) -> URL {
|
func logURL(possiblyRelativeTo resourcesDirectory: URL) -> URL {
|
||||||
guard let logPath else {
|
guard let logPath else {
|
||||||
return resourcesDirectory.appendingPathComponent("logs")
|
return resourcesDirectory.appendingPathComponent("logs")
|
||||||
|
@ -31,7 +31,8 @@ func configure(_ app: Application) async throws {
|
|||||||
app.http.server.configuration.port = config.port
|
app.http.server.configuration.port = config.port
|
||||||
app.routes.defaultMaxBodySize = .init(stringLiteral: config.maxBodySize)
|
app.routes.defaultMaxBodySize = .init(stringLiteral: config.maxBodySize)
|
||||||
|
|
||||||
server = CapServer(in: URL(fileURLWithPath: publicDirectory))
|
let dataDirectory = config.customDataDirectory(or: publicDirectory)
|
||||||
|
server = CapServer(in: dataDirectory)
|
||||||
|
|
||||||
provider = .init(observer: monitor, accessManager: config.writers)
|
provider = .init(observer: monitor, accessManager: config.writers)
|
||||||
provider.asyncScheduler = asyncScheduler
|
provider.asyncScheduler = asyncScheduler
|
||||||
|
Loading…
Reference in New Issue
Block a user