SysConstants.java 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. package com.fdkankan.modeling.constants;
  2. import com.fdkankan.common.util.FileUtils;
  3. import java.util.ArrayList;
  4. import java.util.List;
  5. import java.util.concurrent.ExecutorService;
  6. import java.util.concurrent.Executors;
  7. import org.slf4j.Logger;
  8. import org.slf4j.LoggerFactory;
  9. import org.springframework.beans.factory.annotation.Value;
  10. import org.springframework.stereotype.Component;
  11. @Component
  12. public class SysConstants {
  13. private static final Logger log = LoggerFactory.getLogger(SysConstants.class);
  14. public static String hostName;
  15. public static int modelTimeOut;
  16. public static List<String> residenceServiceHostName = new ArrayList<>();
  17. public static volatile Boolean SYSTEM_BUILDING = false;
  18. public static volatile Boolean SYSTEM_OFFING = false;
  19. public static ExecutorService executorService = Executors.newFixedThreadPool(1);
  20. public static final String DINGTALK_MSG_PATTERN = "**环境**: %s\n\n" +
  21. "**服务器名称**: %s\n\n" +
  22. "**失败原因**: %s\n\n" +
  23. "**num**: %s\n\n" +
  24. "**server-path**: %s\n\n" +
  25. "**algorithm-log**: [https://4dkk.4dage.com/build_log/%s/console.log](https://4dkk.4dage.com/build_log/%s/console.log)";
  26. @Value("${hostName.filePath:/opt/hosts/hosts.txt}")
  27. public void setHostName(String filePath){
  28. try {
  29. SysConstants.hostName = FileUtils.readFile(filePath);
  30. log.error("从文件({})中获取服务器名称:{}", filePath,hostName);
  31. } catch (Exception e) {
  32. log.error("从文件中获取服务器名称失败,文件路径{}", filePath);
  33. e.printStackTrace();
  34. }
  35. }
  36. /**
  37. * 默认超时时间2天
  38. * @param timeOut
  39. */
  40. @Value("${model.timeOut:48}")
  41. public void setModelTimeOut(int timeOut){
  42. SysConstants.modelTimeOut = timeOut;
  43. }
  44. }