提交 c503184e 编写于 作者: Z Zhou Rui

升级命令迁移到ddd中

上级 9afe0c28
...@@ -150,7 +150,7 @@ ...@@ -150,7 +150,7 @@
"enable": false, "enable": false,
"cron": "", "cron": "",
"path": "", "path": "",
"###enable": "是否启用,默认每天凌晨2点进行备份.###", "###enable": "是否启用.###",
"###cron": "定时任务cron表达式###", "###cron": "定时任务cron表达式###",
"###path": "恢复路径###" "###path": "恢复路径###"
}, },
...@@ -158,7 +158,7 @@ ...@@ -158,7 +158,7 @@
"enable": false, "enable": false,
"cron": "", "cron": "",
"path": "", "path": "",
"###enable": "是否启用,默认每天凌晨2点进行备份.###", "###enable": "是否启用.###",
"###cron": "定时任务cron表达式###", "###cron": "定时任务cron表达式###",
"###path": "恢复路径###" "###path": "恢复路径###"
}, },
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
"###enable": "是否启用###", "###enable": "是否启用###",
"###cron": "定时cron表达式###" "###cron": "定时cron表达式###"
}, },
"dataMerge": { "combine": {
"enable": false, "enable": false,
"cron": "30 30 6 * * ?", "cron": "30 30 6 * * ?",
"thresholdDays": 730.0, "thresholdDays": 730.0,
...@@ -66,7 +66,7 @@ ...@@ -66,7 +66,7 @@
"###urge": "催办任务设置,发现即将过期时发送提醒消息.###", "###urge": "催办任务设置,发现即将过期时发送提醒消息.###",
"###expire": "将已经过了截至时间的待办标记过期.###", "###expire": "将已经过了截至时间的待办标记过期.###",
"###touchDelay": "延时任务设置,定时触发延时任务,当超过延时时间后继续流转.###", "###touchDelay": "延时任务设置,定时触发延时任务,当超过延时时间后继续流转.###",
"###dataMerge": "合并任务设置,定时触发合并任务,将已完成工作的Data从Item表中提取合并到WorkCompleted的Data字段中,默认工作完成后2年开始进行合并.###", "###combine": "合并任务设置,定时触发合并任务,将已完成工作的Data从Item表中提取合并到WorkCompleted的Data字段中,默认工作完成后2年开始进行合并.###",
"###deleteDraft": "清除草稿状态的工作.###", "###deleteDraft": "清除草稿状态的工作.###",
"###passExpired": "超时工作路由设置.###", "###passExpired": "超时工作路由设置.###",
"###touchDetained": "触发长时间未处理的工作.###", "###touchDetained": "触发长时间未处理的工作.###",
......
...@@ -48,8 +48,8 @@ public class CommandFactory { ...@@ -48,8 +48,8 @@ public class CommandFactory {
public static final Pattern exit_pattern = Pattern.compile("^ {0,}exit {0,}$", Pattern.CASE_INSENSITIVE); public static final Pattern exit_pattern = Pattern.compile("^ {0,}exit {0,}$", Pattern.CASE_INSENSITIVE);
public static final Pattern updateFile_pattern = Pattern.compile("^ {0,}update file (.+) (true|false) {0,}$", // public static final Pattern updateFile_pattern = Pattern.compile("^ {0,}update file (.+) (true|false) {0,}$",
Pattern.CASE_INSENSITIVE); // Pattern.CASE_INSENSITIVE);
public static final Pattern version_pattern = Pattern.compile("^ {0,}version {0,}$", Pattern.CASE_INSENSITIVE); public static final Pattern version_pattern = Pattern.compile("^ {0,}version {0,}$", Pattern.CASE_INSENSITIVE);
...@@ -110,8 +110,8 @@ public class CommandFactory { ...@@ -110,8 +110,8 @@ public class CommandFactory {
// help += StringUtils.LF; // help += StringUtils.LF;
help += " setPassword (oldpasswd) (newpasswd) change initial manager password."; help += " setPassword (oldpasswd) (newpasswd) change initial manager password.";
help += StringUtils.LF; help += StringUtils.LF;
help += " update file (path) (backup) upgrade to new version from local zip file."; // help += " update file (path) (backup) upgrade to new version from local zip file.";
help += StringUtils.LF; // help += StringUtils.LF;
// help += " compact data (passwd) compact local h2 repository database."; // help += " compact data (passwd) compact local h2 repository database.";
// help += StringUtils.LF; // help += StringUtils.LF;
// help += " erase content (cms|pp|bbs|log) (passwd)" + "\t\t" + "remove all // help += " erase content (cms|pp|bbs|log) (passwd)" + "\t\t" + "remove all
......
...@@ -203,16 +203,6 @@ public class Main { ...@@ -203,16 +203,6 @@ public class Main {
continue; continue;
} }
matcher = CommandFactory.updateFile_pattern.matcher(cmd);
if (matcher.find()) {
if (updateFile(matcher.group(1), matcher.group(2))) {
stopAll();
System.exit(0);
} else {
continue;
}
}
matcher = CommandFactory.setPassword_pattern.matcher(cmd); matcher = CommandFactory.setPassword_pattern.matcher(cmd);
if (matcher.find()) { if (matcher.find()) {
setPassword(matcher.group(1), matcher.group(2)); setPassword(matcher.group(1), matcher.group(2));
...@@ -272,15 +262,6 @@ public class Main { ...@@ -272,15 +262,6 @@ public class Main {
return true; return true;
} }
private static boolean updateFile(String path, String backup) {
try {
return new UpdateFile().execute(path, BooleanUtils.toBoolean(backup));
} catch (Exception e) {
e.printStackTrace();
}
return true;
}
private static void version() { private static void version() {
try { try {
new ActionVersion().execute(); new ActionVersion().execute();
......
...@@ -36,6 +36,7 @@ public class ActionDebugDesignDetail extends ActionBase { ...@@ -36,6 +36,7 @@ public class ActionDebugDesignDetail extends ActionBase {
private static final String CMD_RD = "rd"; private static final String CMD_RD = "rd";
private static final String CMD_RS = "rs"; private static final String CMD_RS = "rs";
private static final String CMD_CLH2 = "clh2"; private static final String CMD_CLH2 = "clh2";
private static final String CMD_UF = "uf";
private static final int REPEAT_MAX = 100; private static final int REPEAT_MAX = 100;
private static final int REPEAT_MIN = 1; private static final int REPEAT_MIN = 1;
...@@ -66,6 +67,8 @@ public class ActionDebugDesignDetail extends ActionBase { ...@@ -66,6 +67,8 @@ public class ActionDebugDesignDetail extends ActionBase {
rs(cmd); rs(cmd);
} else if (cmd.hasOption(CMD_CLH2)) { } else if (cmd.hasOption(CMD_CLH2)) {
clh2(cmd); clh2(cmd);
} else if (cmd.hasOption(CMD_UF)) {
uf(cmd);
} else { } else {
HelpFormatter formatter = new HelpFormatter(); HelpFormatter formatter = new HelpFormatter();
formatter.printHelp("ddd (Debug Design Detail)", options); formatter.printHelp("ddd (Debug Design Detail)", options);
...@@ -87,6 +90,7 @@ public class ActionDebugDesignDetail extends ActionBase { ...@@ -87,6 +90,7 @@ public class ActionDebugDesignDetail extends ActionBase {
options.addOption(rdOption()); options.addOption(rdOption());
options.addOption(rsOption()); options.addOption(rsOption());
options.addOption(clh2Option()); options.addOption(clh2Option());
options.addOption(ufOption());
return options; return options;
} }
...@@ -143,6 +147,11 @@ public class ActionDebugDesignDetail extends ActionBase { ...@@ -143,6 +147,11 @@ public class ActionDebugDesignDetail extends ActionBase {
.desc("将导出的json格式文件数据恢复到存储服务器.").build(); .desc("将导出的json格式文件数据恢复到存储服务器.").build();
} }
private static Option ufOption() {
return Option.builder("uf").longOpt("updateFile").argName("path").hasArg()
.desc("升级服务器,升级前请注意备份.").build();
}
private void ec(CommandLine cmd) throws Exception { private void ec(CommandLine cmd) throws Exception {
if (BooleanUtils.isNotTrue(Config.currentNode().getEraseContentEnable())) { if (BooleanUtils.isNotTrue(Config.currentNode().getEraseContentEnable())) {
logger.print("erase content is disabled."); logger.print("erase content is disabled.");
...@@ -223,6 +232,12 @@ public class ActionDebugDesignDetail extends ActionBase { ...@@ -223,6 +232,12 @@ public class ActionDebugDesignDetail extends ActionBase {
heapDump.execute(); heapDump.execute();
} }
private void uf(CommandLine cmd) throws Exception {
String path = Objects.toString(cmd.getOptionValue(CMD_UF), "");
UpdateFile updateFile= new UpdateFile();
updateFile.execute(path);
}
private Integer getArgInteger(CommandLine cmd, String opt, Integer defaultValue) { private Integer getArgInteger(CommandLine cmd, String opt, Integer defaultValue) {
Integer repeat = defaultValue; Integer repeat = defaultValue;
String r = cmd.getOptionValue(opt); String r = cmd.getOptionValue(opt);
......
package com.x.server.console.action; package com.x.server.console.action;
import java.io.File; import java.io.File;
import java.io.FileFilter;
import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List;
import com.x.base.core.project.config.Config; import com.x.base.core.project.config.Config;
import com.x.base.core.project.logger.Logger; import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory; import com.x.base.core.project.logger.LoggerFactory;
import com.x.base.core.project.tools.DateTools;
import com.x.base.core.project.tools.JarTools; import com.x.base.core.project.tools.JarTools;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
import org.apache.commons.io.filefilter.RegexFileFilter;
/** /**
* @author Zhou Rui * @author Zhou Rui
...@@ -28,17 +23,17 @@ public class UpdateFile extends ActionBase { ...@@ -28,17 +23,17 @@ public class UpdateFile extends ActionBase {
this.start = new Date(); this.start = new Date();
} }
public boolean execute(String path, boolean backup) { public boolean execute(String path) {
try { try {
this.init(); this.init();
File file = new File(path); File file = new File(path);
if (!file.exists() || file.isDirectory()) { if (!file.exists() || file.isDirectory()) {
logger.print("zip file not exist path:{}.", path); logger.print("zip file not exist, path:{}.", path);
return false; return false;
} }
if (backup) { // if (backup) {
this.backup(); // this.backup();
} // }
logger.print("update from file:{}.", file.getAbsolutePath()); logger.print("update from file:{}.", file.getAbsolutePath());
this.unzip(file); this.unzip(file);
logger.print("update completed in {} seconds, restart server to continue update.", logger.print("update completed in {} seconds, restart server to continue update.",
...@@ -50,32 +45,32 @@ public class UpdateFile extends ActionBase { ...@@ -50,32 +45,32 @@ public class UpdateFile extends ActionBase {
} }
} }
private void backup() throws Exception { // private void backup() throws Exception {
File dir = Config.dir_local_backup(true); // File dir = Config.dir_local_backup(true);
String tag = DateTools.compact(new Date()); // String tag = DateTools.compact(new Date());
File dest = new File(dir, tag + ".zip"); // File dest = new File(dir, tag + ".zip");
logger.print("backup current version to {}.", dest.getAbsolutePath()); // logger.print("backup current version to {}.", dest.getAbsolutePath());
List<File> files = new ArrayList<>(); // List<File> files = new ArrayList<>();
files.add(Config.dir_commons()); // files.add(Config.dir_commons());
files.add(Config.dir_config()); // files.add(Config.dir_config());
files.add(Config.dir_configSample()); // files.add(Config.dir_configSample());
files.add(Config.dir_localSample()); // files.add(Config.dir_localSample());
files.add(Config.dir_jvm()); // files.add(Config.dir_jvm());
files.add(Config.dir_servers()); // files.add(Config.dir_servers());
files.add(Config.dir_store()); // files.add(Config.dir_store());
files.add(Config.dir_dynamic()); // files.add(Config.dir_dynamic());
files.add(Config.dir_custom()); // files.add(Config.dir_custom());
files.add(new File(Config.base(), "console.jar")); // files.add(new File(Config.base(), "console.jar"));
files.add(new File(Config.base(), "index.html")); // files.add(new File(Config.base(), "index.html"));
files.add(new File(Config.base(), "version.o2")); // files.add(new File(Config.base(), "version.o2"));
FileFilter fileFilter = new RegexFileFilter( // FileFilter fileFilter = new RegexFileFilter(
"^(start_|stop_|console_|service_)(aix|windows|linux|macos).(sh|bat)$"); // "^(start_|stop_|console_|service_)(aix|windows|linux|macos).(sh|bat)$");
for (File _f : new File(Config.base()).listFiles(fileFilter)) { // for (File _f : new File(Config.base()).listFiles(fileFilter)) {
files.add(_f); // files.add(_f);
} // }
JarTools.jar(files, dest); // JarTools.jar(files, dest);
logger.print("backup current version completed."); // logger.print("backup current version completed.");
} // }
private void unzip(File file) throws Exception { private void unzip(File file) throws Exception {
File dir = Config.dir_local_update(true); File dir = Config.dir_local_update(true);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册