diff --git a/src/main/java/com/leaper/pm2java/service/impl/Pm2JavaServiceImpl.java b/src/main/java/com/leaper/pm2java/service/impl/Pm2JavaServiceImpl.java index d53d850..5569c7d 100644 --- a/src/main/java/com/leaper/pm2java/service/impl/Pm2JavaServiceImpl.java +++ b/src/main/java/com/leaper/pm2java/service/impl/Pm2JavaServiceImpl.java @@ -12,6 +12,7 @@ import com.leaper.pm2java.websocket.WebSocket; import com.sun.management.OperatingSystemMXBean; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import javax.annotation.Resource; @@ -132,10 +133,12 @@ public class Pm2JavaServiceImpl implements Pm2JavaService { return list; } + @Value("${appDire}") + private String appDir; @Override public List search() { List appServerInfos = new ArrayList<>(); - List appServerEntities = FileUtil.readFile(); + List appServerEntities = FileUtil.readFile(appDir); for (AppServerEntity appServerEntity : appServerEntities) { AppServerInfo appServerInfo = new AppServerInfo(); appServerInfo.setName(appServerEntity.getName()); diff --git a/src/main/java/com/leaper/pm2java/util/FileUtil.java b/src/main/java/com/leaper/pm2java/util/FileUtil.java index f3532de..1da1caa 100644 --- a/src/main/java/com/leaper/pm2java/util/FileUtil.java +++ b/src/main/java/com/leaper/pm2java/util/FileUtil.java @@ -3,6 +3,7 @@ package com.leaper.pm2java.util; import com.alibaba.fastjson.JSONObject; import com.leaper.pm2java.entity.AppServerEntity; import com.leaper.pm2java.service.impl.Pm2JavaServiceImpl; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; import java.io.File; @@ -18,6 +19,7 @@ public class FileUtil { static String confPath = "/appConf/"; static String appSuffix = ".appConf"; + //持久化记录为文件 static public boolean saveFile(AppServerEntity appConfigEntity) { appConfigEntity.setType(2); @@ -61,9 +63,14 @@ public class FileUtil { } //持久化记录为文件 - static public List readFile() { + static public List readFile( String appDir) { - String currentFolder = System.getProperty("user.dir"); + String currentFolder; + if( appDir != null && appDir.length() > 0){ + currentFolder = appDir; + }else { + currentFolder = System.getProperty("user.dir"); + } File folder = new File(currentFolder + confPath); File[] files = folder.listFiles(); List list = new ArrayList<>(); diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index f3ab1f4..4666fe9 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -12,3 +12,6 @@ server: logging: config: classpath:logback-spring.xml + + +appDire: D:\hzleaper_auto_install\pm2_java\