| | |
| | | |
| | | @Resource |
| | | private StorageMinioEventMapper storageMinioEventMapper; |
| | | @Value("${minio.accessKey}") |
| | | String accessKey; |
| | | @Value("${minio.secretKey}") |
| | | String secretKey; |
| | | @Value("${minio.path}") |
| | | String path; |
| | | @Value("${minio.enabled}") |
| | | Boolean enabled; |
| | | String processName = "minio.exe"; |
| | | @PostConstruct |
| | | public void initMinio() { |
| | | if (enabled) { |
| | | log.debug("初始化启动minio"); |
| | | |
| | | if (Platform.isWindows()) { |
| | | String exePath = System.getProperty("user.dir") + File.separator + "lib" + File.separator + "minio" + File.separator + processName; |
| | | Map<String, String> env=new HashMap<>(); |
| | | env.put("MINIO_ROOT_USER",accessKey); |
| | | env.put("MINIO_ROOT_PASSWORD",secretKey); |
| | | List<String> cmd = new ArrayList<>(); |
| | | cmd.add(exePath); |
| | | cmd.add("server"); |
| | | cmd.add(path); |
| | | cmd.add("--console-address=0.0.0.0:9000"); |
| | | cmd.add("--address=0.0.0.0:9001"); |
| | | if (CmdUtils.isProcessRunning(processName)) { |
| | | // 进程已经在运行,结束该进程 |
| | | CmdUtils.stopProcess(processName); |
| | | } |
| | | // 启动后台进程 |
| | | CmdUtils.commandStart(processName, cmd, env); |
| | | // 启动cmd窗口 |
| | | //String[] command = {"cmd", "/c", "start", exePath}; |
| | | //CmdUtils.commandStart(command); |
| | | } |
| | | } |
| | | } |
| | | @PreDestroy |
| | | public void destroyMinio() { |
| | | if (enabled) { |
| | | log.info("销毁minio"); |
| | | if (CmdUtils.isProcessRunning(processName)) { |
| | | // 进程已经在运行,结束该进程 |
| | | CmdUtils.stopProcess(processName); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 查询存储事件 |