Change the example config path
This commit is contained in:
4
.gitignore
vendored
4
.gitignore
vendored
@@ -31,5 +31,7 @@ build/
|
|||||||
|
|
||||||
### VS Code ###
|
### VS Code ###
|
||||||
.vscode/
|
.vscode/
|
||||||
|
|
||||||
|
### Custom ###
|
||||||
/application-config.yml
|
/application-config.yml
|
||||||
/application-config.example.yml
|
data
|
||||||
|
|||||||
@@ -14,12 +14,19 @@ class FatWebApiApplication
|
|||||||
fun main(args: Array<String>) {
|
fun main(args: Array<String>) {
|
||||||
val logger = LoggerFactory.getLogger("main")
|
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()) {
|
if (File("application-config.yml").exists()) {
|
||||||
runApplication<FatWebApiApplication>(*args)
|
runApplication<FatWebApiApplication>(*args)
|
||||||
} else {
|
} 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 {
|
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(
|
it.replace(
|
||||||
"\$uuid\$", UUID.randomUUID().toString().replace("-", "")
|
"\$uuid\$", UUID.randomUUID().toString().replace("-", "")
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user