package cn.reghao.bnt.web.ws.event;

import cn.reghao.bnt.common.agent.app.dto.AppInfo;
import cn.reghao.bnt.common.msg.event.EvtAgentStart;
import cn.reghao.bnt.web.devops.app.db.query.AppDeployQuery;
import cn.reghao.bnt.web.devops.app.service.AppRunService;

import java.util.List;

/**
 * @author reghao
 * @date 2021-10-15 16:39:48
 */
public class MachineEventService {
    private AppDeployQuery appDeployQuery;
    private AppRunService appRunService;

    public void start(EvtAgentStart evtAgentStart) {
        // 向 agent 发送 EvtAppStat 事件, 获取应用的状态
        String machineId = evtAgentStart.getMachineId();
        List<AppInfo> list = appDeployQuery.getAppsByMachineId(machineId);
        if (!list.isEmpty()) {
            appRunService.getStat(machineId, list);
        }
    }
}
