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

升级命令迁移到ddd中

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