|
@@ -1,19 +1,14 @@
|
|
|
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 {
|
|
|
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) {
|
|
|
|
|
- this.backup();
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // if (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 {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- 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 {
|
|
private void unzip(File file) throws Exception {
|
|
|
File dir = Config.dir_local_update(true);
|
|
File dir = Config.dir_local_update(true);
|