feiyu02
2024-08-15 196bb14112448857a885e32dc4149e308e00b01a
src/main/kotlin/cn/flightfeather/supervision/SupervisionApplication.kt
@@ -1,17 +1,23 @@
package cn.flightfeather.supervision
import cn.flightfeather.supervision.common.wx.WxTokenManager
import cn.flightfeather.supervision.timingtask.TaskController
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
class SupervisionApplication {
@EnableScheduling
class SupervisionApplication(
    @Value("\${systemIsApp}") var systemIsApp: Boolean,
    @Value("\${mode}") var mode: String,
) {
    @Autowired
    lateinit var webSocketServer: VMRoomWebSocketServer
@@ -24,9 +30,15 @@
    @Bean
    fun runner() = ApplicationRunner {
        webSocketServer.start()
        taskController.run()
        wxTokenManager.run()
        if (systemIsApp) {
            webSocketServer.start()
        } else {
            wxTokenManager.run()
        }
        if (mode == "proapp") {
            taskController.run()
        }
        println("mode: $mode")
    }
}