Cleanup
This commit is contained in:
parent
ddfd2a0e5d
commit
f1de123f9b
21
.github/workflows/v2.yml
vendored
21
.github/workflows/v2.yml
vendored
@ -110,6 +110,12 @@ jobs:
|
||||
username: ${{ secrets.DOCKER_HUB_NAME }}
|
||||
password: ${{ secrets.DOCKER_HUB_TOKEN }}
|
||||
|
||||
- name: Extract version from build.gradle.kts
|
||||
id: extract_version
|
||||
run: |
|
||||
VERSION=$(grep '^version\s*=\s*\".*\"' .\apps\processer\build.gradle.kts | sed 's/^version\s*=\s*\"\(.*\)\"/\1/')
|
||||
echo "::set-output name=version::$VERSION
|
||||
|
||||
- name: Build and push Docker image
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
@ -117,6 +123,7 @@ jobs:
|
||||
file: ./dockerfiles/DebianJavaFfmpeg
|
||||
build-args:
|
||||
MODULE_NAME=processer
|
||||
APP_VERSION=${{ steps.extract_version.outputs.version }}
|
||||
push: true
|
||||
tags: |
|
||||
bskjon/mediaprocessing-processer:v2
|
||||
@ -158,6 +165,12 @@ jobs:
|
||||
username: ${{ secrets.DOCKER_HUB_NAME }}
|
||||
password: ${{ secrets.DOCKER_HUB_TOKEN }}
|
||||
|
||||
- name: Extract version from build.gradle.kts
|
||||
id: extract_version
|
||||
run: |
|
||||
VERSION=$(grep '^version\s*=\s*\".*\"' .\apps\converter\build.gradle.kts | sed 's/^version\s*=\s*\"\(.*\)\"/\1/')
|
||||
echo "::set-output name=version::$VERSION
|
||||
|
||||
- name: Build and push Docker image
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
@ -165,6 +178,7 @@ jobs:
|
||||
file: ./dockerfiles/DebianJava
|
||||
build-args:
|
||||
MODULE_NAME=converter
|
||||
APP_VERSION=${{ steps.extract_version.outputs.version }}
|
||||
push: true
|
||||
tags: |
|
||||
bskjon/mediaprocessing-converter:v2
|
||||
@ -206,6 +220,12 @@ jobs:
|
||||
username: ${{ secrets.DOCKER_HUB_NAME }}
|
||||
password: ${{ secrets.DOCKER_HUB_TOKEN }}
|
||||
|
||||
- name: Extract version from build.gradle.kts
|
||||
id: extract_version
|
||||
run: |
|
||||
VERSION=$(grep '^version\s*=\s*\".*\"' .\apps\coordinator\build.gradle.kts | sed 's/^version\s*=\s*\"\(.*\)\"/\1/')
|
||||
echo "::set-output name=version::$VERSION
|
||||
|
||||
- name: Build and push Docker image
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
@ -213,6 +233,7 @@ jobs:
|
||||
file: ./dockerfiles/DebianJavaFfmpeg
|
||||
build-args:
|
||||
MODULE_NAME=coordinator
|
||||
APP_VERSION=${{ steps.extract_version.outputs.version }}
|
||||
push: true
|
||||
tags: |
|
||||
bskjon/mediaprocessing-coordinator:v2
|
||||
|
||||
@ -1,10 +1,12 @@
|
||||
package no.iktdev.mediaprocessing.converter
|
||||
|
||||
import mu.KotlinLogging
|
||||
import no.iktdev.exfl.coroutines.CoroutinesDefault
|
||||
import no.iktdev.exfl.coroutines.CoroutinesIO
|
||||
import no.iktdev.exfl.observable.Observables
|
||||
import no.iktdev.mediaprocessing.shared.common.DatabaseEnvConfig
|
||||
import no.iktdev.mediaprocessing.shared.common.datasource.MySqlDataSource
|
||||
import no.iktdev.mediaprocessing.shared.common.getAppVersion
|
||||
import no.iktdev.mediaprocessing.shared.common.persistance.PersistentEventManager
|
||||
import no.iktdev.mediaprocessing.shared.common.persistance.TasksManager
|
||||
import no.iktdev.mediaprocessing.shared.common.persistance.tasks
|
||||
@ -27,6 +29,8 @@ fun getContext(): ApplicationContext? {
|
||||
lateinit var taskManager: TasksManager
|
||||
|
||||
private lateinit var eventsDatabase: MySqlDataSource
|
||||
private val log = KotlinLogging.logger {}
|
||||
|
||||
fun getEventsDatabase(): MySqlDataSource {
|
||||
return eventsDatabase
|
||||
}
|
||||
@ -50,5 +54,6 @@ fun main(args: Array<String>) {
|
||||
taskManager = TasksManager(eventsDatabase)
|
||||
|
||||
context = runApplication<ConvertApplication>(*args)
|
||||
log.info { "App Version: ${getAppVersion()}" }
|
||||
}
|
||||
//private val logger = KotlinLogging.logger {}
|
||||
@ -15,12 +15,9 @@ class TaskCoordinator(): TaskCoordinatorBase() {
|
||||
private val log = KotlinLogging.logger {}
|
||||
lateinit var runnerManager: RunnerManager
|
||||
|
||||
@Value("\${appVersion}")
|
||||
private lateinit var version: String
|
||||
|
||||
override fun onCoordinatorReady() {
|
||||
super.onCoordinatorReady()
|
||||
runnerManager = RunnerManager(dataSource = getEventsDatabase(), name = ConvertApplication::class.java.simpleName, version = version)
|
||||
runnerManager = RunnerManager(dataSource = getEventsDatabase(), name = ConvertApplication::class.java.simpleName)
|
||||
runnerManager.assignRunner()
|
||||
}
|
||||
|
||||
|
||||
@ -5,12 +5,9 @@ import mu.KotlinLogging
|
||||
import no.iktdev.exfl.coroutines.CoroutinesDefault
|
||||
import no.iktdev.exfl.coroutines.CoroutinesIO
|
||||
import no.iktdev.exfl.observable.Observables
|
||||
import no.iktdev.mediaprocessing.shared.common.DatabaseEnvConfig
|
||||
import no.iktdev.mediaprocessing.shared.common.SharedConfig
|
||||
import no.iktdev.mediaprocessing.shared.common.*
|
||||
import no.iktdev.mediaprocessing.shared.common.datasource.MySqlDataSource
|
||||
import no.iktdev.mediaprocessing.shared.common.persistance.*
|
||||
import no.iktdev.mediaprocessing.shared.common.toEventsDatabase
|
||||
import no.iktdev.mediaprocessing.shared.common.toStoredDatabase
|
||||
import no.iktdev.mediaprocessing.shared.kafka.core.KafkaEnv
|
||||
import no.iktdev.streamit.library.db.tables.*
|
||||
import no.iktdev.streamit.library.db.tables.helper.cast_errors
|
||||
@ -99,6 +96,8 @@ fun main(args: Array<String>) {
|
||||
|
||||
eventsDatabase.createTables(*kafkaTables.toTypedArray())
|
||||
context = runApplication<CoordinatorApplication>(*args)
|
||||
log.info { "App Version: ${getAppVersion()}" }
|
||||
|
||||
printSharedConfig()
|
||||
}
|
||||
|
||||
|
||||
@ -9,12 +9,6 @@ plugins {
|
||||
group = "no.iktdev.mediaprocessing.apps"
|
||||
version = "1.0-SNAPSHOT"
|
||||
|
||||
val appVersion= "1.0.0"
|
||||
|
||||
tasks.processResources {
|
||||
expand(mapOf("appVersion" to appVersion))
|
||||
}
|
||||
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
|
||||
@ -6,6 +6,7 @@ import no.iktdev.exfl.coroutines.CoroutinesIO
|
||||
import no.iktdev.exfl.observable.Observables
|
||||
import no.iktdev.mediaprocessing.shared.common.DatabaseEnvConfig
|
||||
import no.iktdev.mediaprocessing.shared.common.datasource.MySqlDataSource
|
||||
import no.iktdev.mediaprocessing.shared.common.getAppVersion
|
||||
import no.iktdev.mediaprocessing.shared.common.persistance.*
|
||||
import no.iktdev.mediaprocessing.shared.common.toEventsDatabase
|
||||
import org.jetbrains.exposed.sql.transactions.TransactionManager
|
||||
@ -20,8 +21,6 @@ private val logger = KotlinLogging.logger {}
|
||||
val ioCoroutine = CoroutinesIO()
|
||||
val defaultCoroutine = CoroutinesDefault()
|
||||
|
||||
var taskMode: ActiveMode = ActiveMode.Active
|
||||
|
||||
|
||||
@SpringBootApplication
|
||||
class ProcesserApplication {
|
||||
@ -33,6 +32,7 @@ fun getEventsDatabase(): MySqlDataSource {
|
||||
}
|
||||
|
||||
lateinit var taskManager: TasksManager
|
||||
private val log = KotlinLogging.logger {}
|
||||
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
@ -54,8 +54,9 @@ fun main(args: Array<String>) {
|
||||
|
||||
taskManager = TasksManager(eventsDatabase)
|
||||
|
||||
|
||||
val context = runApplication<ProcesserApplication>(*args)
|
||||
log.info { "App Version: ${getAppVersion()}" }
|
||||
|
||||
}
|
||||
|
||||
@EnableScheduling
|
||||
|
||||
@ -15,12 +15,9 @@ class TaskCoordinator(): TaskCoordinatorBase() {
|
||||
private val log = KotlinLogging.logger {}
|
||||
lateinit var runnerManager: RunnerManager
|
||||
|
||||
@Value("\${appVersion}")
|
||||
private lateinit var version: String
|
||||
|
||||
override fun onCoordinatorReady() {
|
||||
super.onCoordinatorReady()
|
||||
runnerManager = RunnerManager(dataSource = getEventsDatabase(), name = ProcesserApplication::class.java.simpleName, version = version)
|
||||
runnerManager = RunnerManager(dataSource = getEventsDatabase(), name = ProcesserApplication::class.java.simpleName)
|
||||
runnerManager.assignRunner()
|
||||
}
|
||||
|
||||
|
||||
@ -3,3 +3,5 @@ EXPOSE 8080
|
||||
|
||||
ARG MODULE_NAME
|
||||
COPY ./apps/${MODULE_NAME}/build/libs/app.jar /usr/share/app/app.jar
|
||||
|
||||
ENV APP_VERSION
|
||||
@ -3,3 +3,5 @@ EXPOSE 8080
|
||||
|
||||
ARG MODULE_NAME
|
||||
COPY ./apps/${MODULE_NAME}/build/libs/app.jar /usr/share/app/app.jar
|
||||
|
||||
ENV APP_VERSION
|
||||
@ -25,6 +25,13 @@ fun isFileAvailable(file: File): Boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
fun getAppVersion(): Int {
|
||||
val parsed = System.getenv("APP_VERSION")?.let {
|
||||
Regex("\\d+").replace(it, "")
|
||||
} ?: "100"
|
||||
return Integer.parseInt(parsed)
|
||||
}
|
||||
|
||||
fun List<PersistentMessage>.lastOrSuccess(): PersistentMessage? {
|
||||
return this.lastOrNull { it.data.isSuccess() } ?: this.lastOrNull()
|
||||
}
|
||||
|
||||
@ -4,12 +4,13 @@ import mu.KotlinLogging
|
||||
import no.iktdev.mediaprocessing.shared.common.datasource.DataSource
|
||||
import no.iktdev.mediaprocessing.shared.common.datasource.executeOrException
|
||||
import no.iktdev.mediaprocessing.shared.common.datasource.withDirtyRead
|
||||
import no.iktdev.mediaprocessing.shared.common.getAppVersion
|
||||
import org.jetbrains.exposed.sql.and
|
||||
import org.jetbrains.exposed.sql.insert
|
||||
import org.jetbrains.exposed.sql.select
|
||||
import java.util.UUID
|
||||
|
||||
class RunnerManager(private val dataSource: DataSource, val startId: String = UUID.randomUUID().toString(), val name: String, val version: String) {
|
||||
class RunnerManager(private val dataSource: DataSource, private val startId: String = UUID.randomUUID().toString(), val name: String) {
|
||||
private val log = KotlinLogging.logger {}
|
||||
|
||||
fun assignRunner(): Boolean {
|
||||
@ -17,23 +18,22 @@ class RunnerManager(private val dataSource: DataSource, val startId: String = UU
|
||||
runners.insert {
|
||||
it[runners.startId] = this@RunnerManager.startId
|
||||
it[runners.application] = this@RunnerManager.name
|
||||
it[runners.version] = this@RunnerManager.version
|
||||
it[runners.version] = getAppVersion()
|
||||
}
|
||||
} == null
|
||||
}
|
||||
|
||||
private fun versionToVersionCode(version: String?): Int? {
|
||||
return version?.replace(".", "")?.toIntOrNull()
|
||||
}
|
||||
|
||||
fun iAmSuperseded(): Boolean {
|
||||
return withDirtyRead(dataSource.database) {
|
||||
val runnerVersionCodes = runners.select {
|
||||
(runners.application eq this@RunnerManager.version) and
|
||||
(runners.startId neq this@RunnerManager.startId)
|
||||
}.map { it[runners.version] }.mapNotNull { versionToVersionCode(it) }
|
||||
val myVersion = versionToVersionCode(this.version)
|
||||
myVersion?.let {
|
||||
(runners.application eq this@RunnerManager.name) and
|
||||
(runners.startId neq this@RunnerManager.startId)
|
||||
|
||||
}.map { it[runners.version] }
|
||||
|
||||
val myVersion = getAppVersion()
|
||||
myVersion.let {
|
||||
(runnerVersionCodes.any { rv -> rv > it })
|
||||
} ?: true
|
||||
} ?: true
|
||||
|
||||
@ -10,6 +10,6 @@ import java.time.LocalDateTime
|
||||
object runners: IntIdTable() {
|
||||
val startId: Column<String> = varchar("startId", 50)
|
||||
val application: Column<String> = varchar("application", 50)
|
||||
val version: Column<String> = varchar("version", 8)
|
||||
val version: Column<Int> = integer("version")
|
||||
val created: Column<LocalDateTime> = datetime("created").defaultExpression(CurrentDateTime)
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user