package cn.flightfeather.supervision
|
|
import cn.flightfeather.supervision.common.wx.WxTokenManager
|
import cn.flightfeather.supervision.bgtask.TaskController
|
import cn.flightfeather.supervision.websocket.VMRoomWebSocketServer
|
import org.springframework.beans.factory.annotation.Autowired
|
import org.springframework.beans.factory.annotation.Value
|
import org.springframework.boot.ApplicationRunner
|
import org.springframework.boot.autoconfigure.SpringBootApplication
|
import org.springframework.boot.runApplication
|
import org.springframework.context.annotation.Bean
|
import org.springframework.scheduling.annotation.EnableScheduling
|
|
|
@SpringBootApplication
|
@EnableScheduling
|
class SupervisionApplication(
|
@Value("\${systemIsApp}") var systemIsApp: Boolean,
|
@Value("\${mode}") var mode: String,
|
) {
|
|
@Autowired
|
lateinit var webSocketServer: VMRoomWebSocketServer
|
|
@Autowired
|
lateinit var taskController: TaskController
|
|
@Autowired
|
lateinit var wxTokenManager: WxTokenManager
|
|
@Bean
|
fun runner() = ApplicationRunner {
|
if (systemIsApp) {
|
webSocketServer.start()
|
} else {
|
wxTokenManager.run()
|
}
|
if (mode == "proapp") {
|
taskController.run()
|
}
|
println("mode: $mode")
|
}
|
}
|
|
fun main(args: Array<String>) {
|
runApplication<SupervisionApplication>(*args)
|
}
|