diff --git a/README.md b/README.md index 10dea2fa1..cffa3a512 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Jpom(Java Project Online Management)Java项目在线管理 -> 在linux 中管理jar包运行,如SpringBoot、Jboot、jfinal、t-io项目如果是打包为Jar那么我们一般是使用shell 命令来管理, +> 在linux 中管理jar包运行,如SpringBoot、Jboot、jfinal、t-io等项目如果是打包为Jar那么我们一般是使用shell 命令来管理, > 如果有多个项目管理起来显得比较麻烦。 > 如果新增、更新、删除项目都不是很方便。 > 再或者想不使用电脑控制重启、关闭、开启项目。直接使用shell 登录服务器管理显然不是最简单的方法 @@ -33,7 +33,7 @@ 4. cpu、ram 监控 5. 导出堆栈信息 6. 阿里云 CodePipeline + Oss在线管理 -7. 多用户管理 +7. 多用户管理,用户项目权限独立 8. 此项目完全不依赖数据库,随装随用 9. 整个服务器top监听 10. 查看项目运行进程占用的端口 @@ -96,7 +96,7 @@ mvn package 访问[Jpom](https://gitee.com/keepbx/jpom)的码云主页,拉取最新完整代码: 1. 运行*cn.keepbx.jpom.JpomApplication* -2. 浏览器访问 +2. 浏览器访问(如:http://127.0.0.1:2122) ### 常见问题 diff --git a/src/main/java/cn/keepbx/jpom/service/BaseDataService.java b/src/main/java/cn/keepbx/jpom/service/BaseDataService.java index 81ac5d3e2..91d8f6ed5 100644 --- a/src/main/java/cn/keepbx/jpom/service/BaseDataService.java +++ b/src/main/java/cn/keepbx/jpom/service/BaseDataService.java @@ -8,10 +8,12 @@ import com.alibaba.fastjson.JSONObject; import java.io.IOException; /** + * 公共文件操作Service + * * @author jiangzeyin * @date 2019/1/16 */ -public class BaseDataService extends BaseService { +public abstract class BaseDataService { /** * 获取数据文件的路径,如果文件不存在,则创建一个 @@ -28,7 +30,7 @@ public class BaseDataService extends BaseService { * * @param filename 文件名 * @param json json数据 - * @throws Exception + * @throws Exception 异常 */ protected void saveJson(String filename, JSONObject json) throws Exception { String key = json.getString("id"); diff --git a/src/main/java/cn/keepbx/jpom/service/BaseService.java b/src/main/java/cn/keepbx/jpom/service/BaseService.java deleted file mode 100644 index 8958db5ea..000000000 --- a/src/main/java/cn/keepbx/jpom/service/BaseService.java +++ /dev/null @@ -1,8 +0,0 @@ -package cn.keepbx.jpom.service; - -/** - * @author jiangzeyin - */ -public abstract class BaseService { - -} diff --git a/src/main/java/cn/keepbx/jpom/service/UserService.java b/src/main/java/cn/keepbx/jpom/service/UserService.java index 8e3825587..dd2738090 100644 --- a/src/main/java/cn/keepbx/jpom/service/UserService.java +++ b/src/main/java/cn/keepbx/jpom/service/UserService.java @@ -4,16 +4,20 @@ import cn.hutool.core.util.StrUtil; import cn.jiangzeyin.common.DefaultSystemLog; import cn.keepbx.jpom.model.UserModel; import cn.keepbx.jpom.system.ConfigBean; +import cn.keepbx.jpom.system.init.CheckRunCommand; import cn.keepbx.jpom.util.JsonUtil; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import org.springframework.stereotype.Service; +import java.io.FileNotFoundException; import java.io.IOException; import java.util.Map; import java.util.Set; /** + * 用户管理 + * * @author Administrator */ @Service @@ -25,11 +29,14 @@ public class UserService extends BaseDataService { * 用户列表是否为空 * * @return true 为空需要初始化 - * @throws IOException 异常 */ - public boolean userListEmpty() throws IOException { - JSONObject userInfo = getJsonObject(FILENAME); - return userInfo.isEmpty(); + public boolean userListEmpty() { + try { + JSONObject userInfo = getJsonObject(FILENAME); + return userInfo.isEmpty(); + } catch (Exception ignored) { + } + return true; } /** @@ -215,8 +222,11 @@ public class UserService extends BaseDataService { try { saveJson(FILENAME, userModel.toJson()); return true; + } catch (FileNotFoundException fileNotFoundException) { + CheckRunCommand.repairData(); + return addUser(userModel); } catch (Exception e) { - DefaultSystemLog.LOG().error(e.getMessage(), e); + DefaultSystemLog.ERROR().error(e.getMessage(), e); } return false; } diff --git a/src/main/java/cn/keepbx/jpom/service/manage/CommandService.java b/src/main/java/cn/keepbx/jpom/service/manage/CommandService.java index 5e3574318..c65d86723 100644 --- a/src/main/java/cn/keepbx/jpom/service/manage/CommandService.java +++ b/src/main/java/cn/keepbx/jpom/service/manage/CommandService.java @@ -5,7 +5,6 @@ import cn.hutool.core.io.IoUtil; import cn.hutool.core.util.CharsetUtil; import cn.jiangzeyin.common.DefaultSystemLog; import cn.keepbx.jpom.model.ProjectInfoModel; -import cn.keepbx.jpom.service.BaseService; import cn.keepbx.jpom.socket.LogWebSocketHandle; import cn.keepbx.jpom.socket.SocketSession; import cn.keepbx.jpom.socket.TailLogThread; @@ -24,7 +23,7 @@ import java.io.InputStream; * @author jiangzeyin */ @Service -public class CommandService extends BaseService { +public class CommandService { public static final String RUNING_TAG = "running"; public static final String STOP_TAG = "stopped"; diff --git a/src/main/java/cn/keepbx/jpom/service/manage/ManageService.java b/src/main/java/cn/keepbx/jpom/service/manage/ManageService.java index cdd271991..bb8d0a947 100644 --- a/src/main/java/cn/keepbx/jpom/service/manage/ManageService.java +++ b/src/main/java/cn/keepbx/jpom/service/manage/ManageService.java @@ -24,8 +24,8 @@ public class ManageService extends BaseDataService { /** * 查询所有项目信息 * - * @return - * @throws IOException + * @return json + * @throws IOException 异常 */ public JSONObject getAllProjectInfo() throws IOException { return getJsonObject(FILENAME); @@ -34,8 +34,7 @@ public class ManageService extends BaseDataService { /** * 保存项目信息 * - * @param projectInfo - * @return + * @param projectInfo 项目 */ public void saveProject(ProjectInfoModel projectInfo) throws Exception { // 保存 @@ -45,7 +44,7 @@ public class ManageService extends BaseDataService { /** * 删除项目 * - * @param id + * @param id 项目Id */ public void deleteProject(String id) throws Exception { deleteJson(FILENAME, id); diff --git a/src/main/java/cn/keepbx/jpom/system/init/CheckRunCommand.java b/src/main/java/cn/keepbx/jpom/system/init/CheckRunCommand.java index 9adc2a691..2ab883d5c 100644 --- a/src/main/java/cn/keepbx/jpom/system/init/CheckRunCommand.java +++ b/src/main/java/cn/keepbx/jpom/system/init/CheckRunCommand.java @@ -66,6 +66,13 @@ public class CheckRunCommand { } } + /** + * 修护检查 + */ + public static void repairData() { + checkData(); + } + private static void addDataFile(String name, String file) { URL url = ResourceUtil.getResource("bin/data/" + name); String content = FileUtil.readString(url, CharsetUtil.UTF_8); diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 2f5a7b124..df0780ac0 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -21,7 +21,7 @@ spring: resource-loader-path: classpath:/vm/ suffix: .vm banner: - msg: jpom 管理系统启动中 + msg: Jpom 管理系统启动中 #jpom 项目运行路径 jpom: path: /jpom/ diff --git a/src/main/resources/logback-spring.xml b/src/main/resources/logback-spring.xml index a30ac3c85..2689aca90 100644 --- a/src/main/resources/logback-spring.xml +++ b/src/main/resources/logback-spring.xml @@ -1,5 +1,6 @@ +