feiyu02
2025-09-30 6904763f0e74d9a9fa4dbc39f635d2aee39416c6
src/main/kotlin/cn/flightfeather/supervision/SupervisionApplication.kt
@@ -1,16 +1,22 @@
package cn.flightfeather.supervision
import cn.flightfeather.supervision.timingtask.TaskController
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
class SupervisionApplication {
@EnableScheduling
class SupervisionApplication(
    @Value("\${mode}") var mode: String,
) {
    @Autowired
    lateinit var webSocketServer: VMRoomWebSocketServer
@@ -18,10 +24,22 @@
    @Autowired
    lateinit var taskController: TaskController
    @Autowired
    lateinit var wxTokenManager: WxTokenManager
    @Bean
    fun runner() = ApplicationRunner {
        webSocketServer.start()
//        taskController.run()
        taskController.run()
        // 2023.8.20 应用于安卓app后台,后续应该合并于小程序后台
        if (mode == "proapp") {
//            webSocketServer.start()
        }
        // 应用于微信小程序后台
        else if (mode == "pro") {
            wxTokenManager.run()
            webSocketServer.start()
        }
        println("mode: $mode")
    }
}