File tree Expand file tree Collapse file tree 2 files changed +51
-0
lines changed
src/main/kotlin/uk/gov/communities/prsdb/webapp/application Expand file tree Collapse file tree 2 files changed +51
-0
lines changed Original file line number Diff line number Diff line change 1+ package uk.gov.communities.prsdb.webapp.application
2+
3+ import org.springframework.boot.ApplicationArguments
4+ import org.springframework.boot.ApplicationRunner
5+ import org.springframework.boot.SpringApplication
6+ import org.springframework.context.ApplicationContext
7+ import org.springframework.context.annotation.Profile
8+ import org.springframework.core.Ordered
9+ import org.springframework.core.annotation.Order
10+ import org.springframework.stereotype.Component
11+ import kotlin.system.exitProcess
12+
13+ @Component
14+ @Profile(" web-server-deactivated & scheduled-task" )
15+ @Order(Ordered .LOWEST_PRECEDENCE )
16+ class DefaultScheduledTaskApplicationRunner (
17+ private val context : ApplicationContext ,
18+ ) : ApplicationRunner {
19+ override fun run (args : ApplicationArguments ? ) {
20+ println (" The application was not configured for this scheduled task. Application will exit now." )
21+
22+ val code =
23+ SpringApplication .exit(context, { 0 })
24+ exitProcess(code)
25+ }
26+ }
Original file line number Diff line number Diff line change 1+ package uk.gov.communities.prsdb.webapp.application
2+
3+ import org.springframework.boot.ApplicationArguments
4+ import org.springframework.boot.ApplicationRunner
5+ import org.springframework.boot.SpringApplication
6+ import org.springframework.context.ApplicationContext
7+ import org.springframework.context.annotation.Profile
8+ import org.springframework.stereotype.Component
9+ import kotlin.system.exitProcess
10+
11+ @Component
12+ @Profile(" web-server-deactivated & scheduled-task & example-scheduled-task" )
13+ class ExampleScheduledTaskApplicationRunner (
14+ private val context : ApplicationContext ,
15+ ) : ApplicationRunner {
16+ override fun run (args : ApplicationArguments ? ) {
17+ println (" Executing example scheduled task" )
18+
19+ val code =
20+ SpringApplication .exit(context, { 0 }).also {
21+ println (" Scheduled task executed. Application will exit now." )
22+ }
23+ exitProcess(code)
24+ }
25+ }
You can’t perform that action at this time.
0 commit comments