From 82c9fcb10fb9b6cb394ccc231459e09ba287bce8 Mon Sep 17 00:00:00 2001 From: FatttSnake Date: Sun, 8 Oct 2023 23:33:59 +0800 Subject: [PATCH] Change the example config path --- .gitignore | 4 +++- .../kotlin/top/fatweb/api/FatWebApiApplication.kt | 11 +++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 318632d..d65ea6e 100644 --- a/.gitignore +++ b/.gitignore @@ -31,5 +31,7 @@ build/ ### VS Code ### .vscode/ + +### Custom ### /application-config.yml -/application-config.example.yml +data diff --git a/src/main/kotlin/top/fatweb/api/FatWebApiApplication.kt b/src/main/kotlin/top/fatweb/api/FatWebApiApplication.kt index 1920cd3..3c635e2 100644 --- a/src/main/kotlin/top/fatweb/api/FatWebApiApplication.kt +++ b/src/main/kotlin/top/fatweb/api/FatWebApiApplication.kt @@ -14,12 +14,19 @@ class FatWebApiApplication fun main(args: Array) { val logger = LoggerFactory.getLogger("main") + if (!File("data").isDirectory) { + if (!File("data").mkdir()) { + logger.error("Can not create directory 'data', please try again later.") + return + } + } + if (File("application-config.yml").exists()) { runApplication(*args) } else { - logger.warn("File ‘application.yml’ cannot be found in the running path. The configuration file template 'application.example.yml' has been created. Please change the configuration file content and rename it to 'application.yml', and then restart the server.") + logger.warn("File ‘application.yml’ cannot be found in the running path. The configuration file template 'application.example.yml' has been created in directory 'data'. Please change the configuration file content, rename it to 'application.yml' and put it in the running path, and then restart the server.") FatWebApiApplication::class.java.getResource("/application-config-template.yml")?.readText()?.let { - File("application-config.example.yml").writeText( + File("data/application-config.example.yml").writeText( it.replace( "\$uuid\$", UUID.randomUUID().toString().replace("-", "") )