HB, OTA etc
This commit is contained in:
@@ -20,6 +20,7 @@ dependencies {
|
||||
implementation("ch.qos.logback:logback-classic:1.4.14")
|
||||
implementation("org.mariadb.jdbc:mariadb-java-client:3.3.3")
|
||||
implementation("com.zaxxer:HikariCP:5.1.0")
|
||||
implementation("io.ktor:ktor-server-compression:2.3.7")
|
||||
testImplementation(kotlin("test"))
|
||||
}
|
||||
|
||||
@@ -43,4 +44,49 @@ tasks.processResources {
|
||||
from("../db/migrations") {
|
||||
into("db/migration")
|
||||
}
|
||||
}
|
||||
|
||||
tasks.register("deploy") {
|
||||
dependsOn("jar")
|
||||
|
||||
doLast {
|
||||
val jarFile = file("build/libs/backend.jar")
|
||||
|
||||
if (!jarFile.exists()) {
|
||||
throw GradleException("Jar not found: ${jarFile.absolutePath}")
|
||||
}
|
||||
|
||||
fun runCommand(vararg cmd: String) {
|
||||
println("Running: ${cmd.joinToString(" ")}")
|
||||
|
||||
val process = ProcessBuilder(*cmd)
|
||||
.inheritIO()
|
||||
.start()
|
||||
|
||||
val exitCode = process.waitFor()
|
||||
if (exitCode != 0) {
|
||||
throw GradleException("Command failed: ${cmd.joinToString(" ")}")
|
||||
}
|
||||
}
|
||||
|
||||
// upload
|
||||
runCommand(
|
||||
"scp",
|
||||
jarFile.absolutePath,
|
||||
"home-iot:/tmp/backend.jar"
|
||||
)
|
||||
|
||||
// deploy
|
||||
runCommand(
|
||||
"ssh",
|
||||
"home-iot",
|
||||
"sudo mv /tmp/backend.jar /opt/iot-backend/app.jar && sudo systemctl restart iot-backend"
|
||||
)
|
||||
|
||||
runCommand("ssh",
|
||||
"home-iot",
|
||||
"systemctl status iot-backend --no-pager")
|
||||
|
||||
println("Deploy completed")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user