ModelingApplication.java 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. package com.fdkankan.modeling;
  2. import cn.hutool.core.collection.CollUtil;
  3. import cn.hutool.core.io.FileUtil;
  4. import cn.hutool.core.util.StrUtil;
  5. import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  6. import com.fdkankan.model.utils.CreateObjUtil;
  7. import com.fdkankan.modeling.constants.SysConstants;
  8. import com.fdkankan.modeling.entity.BuildLog;
  9. import com.fdkankan.modeling.service.IBuildLogService;
  10. import lombok.extern.slf4j.Slf4j;
  11. import org.mybatis.spring.annotation.MapperScan;
  12. import org.springframework.beans.factory.annotation.Autowired;
  13. import org.springframework.boot.CommandLineRunner;
  14. import org.springframework.boot.SpringApplication;
  15. import org.springframework.boot.autoconfigure.SpringBootApplication;
  16. import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
  17. import org.springframework.context.annotation.ComponentScan;
  18. import org.springframework.scheduling.annotation.EnableScheduling;
  19. import java.util.List;
  20. @SpringBootApplication
  21. @EnableScheduling
  22. @ComponentScan(basePackages = {"com.fdkankan.*"})
  23. @MapperScan("com.fdkankan.**.mapper")
  24. @EnableDiscoveryClient
  25. @Slf4j
  26. public class ModelingApplication implements CommandLineRunner {
  27. @Autowired
  28. private IBuildLogService buildLogService;
  29. public static void main(String[] args) {
  30. SpringApplication.run(ModelingApplication.class, args);
  31. //进入计算之前,把上次未关闭的算法杀掉(主要是重启的问题)
  32. CreateObjUtil.killMainLoader();
  33. }
  34. @Override
  35. public void run(String... args) throws Exception {
  36. // String lockPath = null;
  37. // try {
  38. // if(StrUtil.isNotEmpty(SysConstants.hostName)){
  39. // List<BuildLog> list = buildLogService.list(new LambdaQueryWrapper<BuildLog>().eq(BuildLog::getHostName, SysConstants.hostName).eq(BuildLog::getStatus, 0).orderByDesc(BuildLog::getId));
  40. // if(CollUtil.isNotEmpty(list)){
  41. // BuildLog buildLog = list.get(0);
  42. // lockPath = buildLog.getDataSource() + "/.lockdirectory";
  43. // if(FileUtil.exist(lockPath)){
  44. // FileUtil.del(lockPath);
  45. // }
  46. // }
  47. // }
  48. // }catch (Exception e){
  49. // log.warn("删除上一计算中场景文件锁失败,logPath:{}", lockPath, e);
  50. // }
  51. }
  52. }