Change the example config path

This commit is contained in:
2023-10-08 23:33:59 +08:00
parent 723bdd4c29
commit 82c9fcb10f
2 changed files with 12 additions and 3 deletions

4
.gitignore vendored
View File

@@ -31,5 +31,7 @@ build/
### VS Code ###
.vscode/
### Custom ###
/application-config.yml
/application-config.example.yml
data

View File

@@ -14,12 +14,19 @@ class FatWebApiApplication
fun main(args: Array<String>) {
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<FatWebApiApplication>(*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("-", "")
)