import { initConfig, systemConfig} from "./config/serverConfig";
import * as mysqlDB from "./db/mysqlInit";
import * as mqttSrv from "./service/mqttInit";
import { initMysqlModel } from "./model/sqlModelBind";
import { httpServer } from "./net/http_server";
import { startSchedule, startAlertSchedule, startFaultStatusSchedule } from "./config/schedule";
import { initScheduleTasks } from "./biz/scheduleExecutor";
import { refreshRegionSortOrder } from "./biz/region";


async function lanuch() {
    /**初始化配置解析 */
    await initConfig();
    /**初始化sql */
    await mysqlDB.initMysqlDB();
    await initMysqlModel();
    /**刷新区域排序 */
    await refreshRegionSortOrder();
    /**创建http服务 */
    httpServer.createServer(systemConfig.port);
    /**启动MQTT订阅服务 */
    await mqttSrv.startMqttClient();
    /**启动定时任务 */
    startSchedule();
    /**启动预警工单定时任务（10分钟） */
    startAlertSchedule();
    /**启动故障状态更新定时任务（5分钟） */
    startFaultStatusSchedule();
    /**启动日程执行器 */
    await initScheduleTasks();

    console.log('This indicates that the server is started successfully.');

}

lanuch();




