Skip to content

Commit

Permalink
Wrap hele greia i en try-catch, som forhåpentligvis unngår at appen t…
Browse files Browse the repository at this point in the history
…ryner og henger
  • Loading branch information
hermanwh committed Aug 18, 2023
1 parent 78d0d0e commit 9f06c71
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/main/kotlin/no/digipost/github/monitoring/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,28 @@ import org.slf4j.LoggerFactory
import java.nio.file.Files
import java.nio.file.Path
import java.util.concurrent.atomic.AtomicLong
import kotlin.system.exitProcess
import kotlin.system.measureTimeMillis

val LANGUAGES = setOf("JavaScript", "Java", "TypeScript", "C#", "Kotlin", "Go")
val POSSIBLE_CONTAINER_SCAN = setOf("JavaScript", "Java", "TypeScript", "Kotlin")

suspend fun main(): Unit = coroutineScope {
val logger = LoggerFactory.getLogger("no.digipost.github.monitoring.Main")
try {
runServer()
} catch (e: Exception) {
logger.error("Noe fatalt skjedde under kjøring av github-monitoring, stopper prosessen", e)
exitProcess(1)
}
}

suspend fun runServer(): Unit = coroutineScope {
val env = System.getenv("env")
val token = if (env == "local") System.getenv("token") else withContext(Dispatchers.IO) {
Files.readString(Path.of("/secrets/githubtoken.txt")).trim()
}

val logger = LoggerFactory.getLogger("no.digipost.github.monitoring.Main")
val prometheusMeterRegistry = PrometheusMeterRegistry(PrometheusConfig.DEFAULT)

ApplicationInfoMetrics().bindTo(prometheusMeterRegistry)
Expand Down

0 comments on commit 9f06c71

Please sign in to comment.