1
0
forked from SPC/spc-site

update CD

This commit is contained in:
Alexander Nozik 2022-05-25 21:52:55 +03:00
parent 73949a23cb
commit 99eab81cb3
No known key found for this signature in database
GPG Key ID: F7FCF2DD25C71357
2 changed files with 6 additions and 4 deletions

View File

@ -19,7 +19,9 @@ job("Deploy") {
shellScript {
interpreter = "/bin/bash"
content = "echo \$ID | ssh -i /dev/stdin -r /mnt/space/share/spc-site/ \"\$USER@\$HOST:/opt\""
content = """
echo ${'$'}ID | ssh -i /dev/stdin -r /mnt/space/share/spc-site/ "${'$'}USER@${'$'}HOST:/opt"
""".trimIndent()
}
}
}

View File

@ -51,13 +51,13 @@ fun Application.spcModule() {
val dataPath = Path.of("data")
// Clear data directory if it is outdated
val deployDate = dataPath.resolve(DEPLOY_DATE_FILE).takeIf { it.exists() }
?.readText()?.let { LocalDateTime.parse(it) }
val buildDate = javaClass.getResource(BUILD_DATE_FILE)?.readText()?.let { LocalDateTime.parse(it) }
val inProduction = environment.config.propertyOrNull("ktor.inProduction") != null
if (deployDate != null && buildDate != null && buildDate.isAfter(deployDate)) {
log.info("Outdated data. Resetting data directory.")
@ -69,7 +69,7 @@ fun Application.spcModule() {
dataPath.createDirectories()
dataPath.resolve(DEPLOY_DATE_FILE).writeText(LocalDateTime.now().toString())
} else if (System.getProperty("spc-production") == "true" && deployDate == null && buildDate != null) {
} else if (inProduction && deployDate == null && buildDate != null) {
//Writing deploy date in production mode if it does not exist
dataPath.createDirectories()