Skip to content

Commit

Permalink
0004862: Create WAR gets instance.uuid does not exist
Browse files Browse the repository at this point in the history
  • Loading branch information
erilong committed Mar 1, 2021
1 parent 51a4aae commit 64ccf38
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Expand Up @@ -133,7 +133,7 @@ public class SymmetricAdmin extends AbstractCommandLauncher {

private static final String CMD_RESTORE_FILE_CONFIGURATION = "restore-config";

private static final String[] NO_ENGINE_REQUIRED = { CMD_EXPORT_PROPERTIES, CMD_ENCRYPT_TEXT, CMD_OBFUSCATE_TEXT, CMD_LIST_ENGINES, CMD_MODULE, CMD_BACKUP_FILE_CONFIGURATION, CMD_RESTORE_FILE_CONFIGURATION };
private static final String[] NO_ENGINE_REQUIRED = { CMD_EXPORT_PROPERTIES, CMD_ENCRYPT_TEXT, CMD_OBFUSCATE_TEXT, CMD_LIST_ENGINES, CMD_MODULE, CMD_BACKUP_FILE_CONFIGURATION, CMD_RESTORE_FILE_CONFIGURATION, CMD_CREATE_WAR };

private static final String OPTION_NODE = "node";

Expand Down Expand Up @@ -683,7 +683,10 @@ private void generateWar(CommandLine line, List<String> args) throws Exception {
final File workingDirectory = new File(AppUtils.getSymHome() + "/.war");
FileUtils.deleteDirectory(workingDirectory);
FileUtils.copyDirectory(new File(AppUtils.getSymHome() + "/web"), workingDirectory);
FileUtils.copyToDirectory(new File(AppUtils.getSymHome() + "/conf/instance.uuid"), new File(workingDirectory, "WEB-INF/classes"));
File instanceIdFile = new File(AppUtils.getSymHome() + "/conf/instance.uuid");
if (instanceIdFile.canRead()) {
FileUtils.copyToDirectory(instanceIdFile, new File(workingDirectory, "WEB-INF/classes"));
}

boolean useProperties = (line.hasOption(OPTION_PROPERTIES_FILE) || line.hasOption(OPTION_ENGINE)) &&
propertiesFile != null && propertiesFile.exists();
Expand Down
Expand Up @@ -162,9 +162,6 @@ protected void initInstanceId() {
instanceIdFile = defaultFile;
} else {
instanceIdURL = getClass().getClassLoader().getResource("/instance.uuid");
if (instanceIdURL == null) {
instanceIdFile = defaultFile;
}
}

if (instanceIdFile != null) {
Expand Down Expand Up @@ -194,12 +191,12 @@ protected void initInstanceId() {
if (newInstanceId == null) {
newInstanceId = generateInstanceId(AppUtils.getHostName());
}
instanceId = newInstanceId;
isUpgradedInstanceId = true;
if (instanceIdFile != null) {
try {
instanceIdFile.getParentFile().mkdirs();
IOUtils.write(newInstanceId, new FileOutputStream(instanceIdFile), Charset.defaultCharset());
instanceId = newInstanceId;
isUpgradedInstanceId = true;
} catch (Exception ex) {
throw new SymmetricException("Failed to save file '" + instanceIdFile + "' Please correct and restart this node.", ex);
}
Expand Down

0 comments on commit 64ccf38

Please sign in to comment.