package com.fdkankan.modeling; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.io.FileUtil; import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.fdkankan.model.utils.CreateObjUtil; import com.fdkankan.modeling.constants.SysConstants; import com.fdkankan.modeling.entity.BuildLog; import com.fdkankan.modeling.service.IBuildLogService; import lombok.extern.slf4j.Slf4j; import org.mybatis.spring.annotation.MapperScan; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.CommandLineRunner; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.context.annotation.ComponentScan; import org.springframework.scheduling.annotation.EnableScheduling; import java.util.List; @SpringBootApplication @EnableScheduling @ComponentScan(basePackages = {"com.fdkankan.*"}) @MapperScan("com.fdkankan.**.mapper") @EnableDiscoveryClient @Slf4j public class ModelingApplication implements CommandLineRunner { @Autowired private IBuildLogService buildLogService; public static void main(String[] args) { SpringApplication.run(ModelingApplication.class, args); //进入计算之前,把上次未关闭的算法杀掉(主要是重启的问题) CreateObjUtil.killMainLoader(); } @Override public void run(String... args) throws Exception { // String lockPath = null; // try { // if(StrUtil.isNotEmpty(SysConstants.hostName)){ // List list = buildLogService.list(new LambdaQueryWrapper().eq(BuildLog::getHostName, SysConstants.hostName).eq(BuildLog::getStatus, 0).orderByDesc(BuildLog::getId)); // if(CollUtil.isNotEmpty(list)){ // BuildLog buildLog = list.get(0); // lockPath = buildLog.getDataSource() + "/.lockdirectory"; // if(FileUtil.exist(lockPath)){ // FileUtil.del(lockPath); // } // } // } // }catch (Exception e){ // log.warn("删除上一计算中场景文件锁失败,logPath:{}", lockPath, e); // } } }