Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package uk.gov.communities.prsdb.webapp.application

import org.springframework.boot.ApplicationArguments
import org.springframework.boot.ApplicationRunner
import org.springframework.boot.SpringApplication
import org.springframework.context.ApplicationContext
import org.springframework.context.annotation.Profile
import org.springframework.core.Ordered
import org.springframework.core.annotation.Order
import org.springframework.stereotype.Component
import kotlin.system.exitProcess

@Component
@Profile("web-server-deactivated & scheduled-task")
@Order(Ordered.LOWEST_PRECEDENCE)
class DefaultScheduledTaskApplicationRunner(
private val context: ApplicationContext,
) : ApplicationRunner {
override fun run(args: ApplicationArguments?) {
println("The application was not configured for this scheduled task. Application will exit now.")

val code =
SpringApplication.exit(context, { 0 })
exitProcess(code)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package uk.gov.communities.prsdb.webapp.application

import org.springframework.boot.ApplicationArguments
import org.springframework.boot.ApplicationRunner
import org.springframework.boot.SpringApplication
import org.springframework.context.ApplicationContext
import org.springframework.context.annotation.Profile
import org.springframework.stereotype.Component
import kotlin.system.exitProcess

@Component
@Profile("web-server-deactivated & scheduled-task & example-scheduled-task")
class ExampleScheduledTaskApplicationRunner(
private val context: ApplicationContext,
) : ApplicationRunner {
override fun run(args: ApplicationArguments?) {
println("Executing example scheduled task")

val code =
SpringApplication.exit(context, { 0 }).also {
println("Scheduled task executed. Application will exit now.")
}
exitProcess(code)
}
}
Loading