I’d like to launch a long-running background job a...
# ktor
c
I’d like to launch a long-running background job at application startup. I noticed the kotlinconf-app does this: https://github.com/JetBrains/kotlinconf-app/blob/master/backend/src/org/jetbrains/kotlinconf/backend/Sessionize.kt#L25
Copy code
fun Application.launchSyncJob(sessionizeUrl: String, sessionizeInterval: Long) {
    <http://log.info|log.info>("Synchronizing each $sessionizeInterval minutes with $sessionizeUrl")
    GlobalScope.launch {
        while (true) {
...
I was wondering why it uses
GlobalScope
instead of the
Application
CoroutineScope
? Is there a reason to prefer one or the other for this sort of thing? (Assume the background job should run for as long as the Application is up.)