From 99eab81cb30ee567ea8925511bf5615747068e2e Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Wed, 25 May 2022 21:52:55 +0300 Subject: [PATCH] update CD --- .space.kts | 4 +++- src/main/kotlin/ru/mipt/spc/Application.kt | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.space.kts b/.space.kts index 8c72259..8986031 100644 --- a/.space.kts +++ b/.space.kts @@ -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() } } } \ No newline at end of file diff --git a/src/main/kotlin/ru/mipt/spc/Application.kt b/src/main/kotlin/ru/mipt/spc/Application.kt index f262ffb..a558e43 100644 --- a/src/main/kotlin/ru/mipt/spc/Application.kt +++ b/src/main/kotlin/ru/mipt/spc/Application.kt @@ -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()