Skip to content

Commit

Permalink
0002158: Snapshot util should just package up all files with the .log…
Browse files Browse the repository at this point in the history
… extension in the log directory
  • Loading branch information
chenson42 committed Jan 26, 2015
1 parent e75c4f5 commit 086b8dd
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 36 deletions.
Expand Up @@ -61,7 +61,6 @@
import org.jumpmind.symmetric.service.IClusterService;
import org.jumpmind.symmetric.service.INodeService;
import org.jumpmind.symmetric.service.ITriggerRouterService;
import org.jumpmind.util.AppUtils;
import org.jumpmind.util.JarBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -81,34 +80,34 @@ public static File createSnapshot(ISymmetricEngine engine) {

String dirName = engine.getEngineName().replaceAll(" ", "-") + "-" + new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());

File snapshotsDir = getSnapshotDirectory(engine);

File logfile = new File(AppUtils.getCanonicalSymHome(engine.getParameterService().getString(ParameterConstants.SERVER_LOG_FILE)));
//File snapshotsDir = getSnapshotDirectory(engine);

File tmpDir = new File(engine.getParameterService().getTempDirectory(), dirName);
tmpDir.mkdirs();

if (logfile.exists() && logfile.isFile()) {
try {
FileUtils.copyFileToDirectory(logfile, tmpDir);
} catch (IOException e) {
log.warn("Failed to copy the log file to the snapshot directory", e);
}
} else {
log.warn("Could not find {} to copy to the snapshot directory",
logfile.getAbsolutePath());
File logDir = new File("logs");

if (!logDir.exists()) {
logDir = new File("../logs");
}

File serviceWrapperLogFile = new File(AppUtils.getSymHome() + "/logs/wrapper.log");
if (serviceWrapperLogFile.exists() && serviceWrapperLogFile.isFile()) {
try {
FileUtils.copyFileToDirectory(serviceWrapperLogFile, tmpDir);
} catch (IOException e) {
log.warn("Failed to copy the wrapper.log file to the snapshot directory", e);

if (!logDir.exists()) {
logDir = new File("target");
}

if (logDir.exists()) {
File[] files = logDir.listFiles();
if (files != null) {
for (File file : files) {
if (file.getName().toLowerCase().endsWith(".log")) {
try {
FileUtils.copyFileToDirectory(file, tmpDir);
} catch (IOException e) {
log.warn("Failed to copy "+file.getName()+" to the snapshot directory", e);
}
}
}
}
} else {
log.debug("Could not find {} to copy to the snapshot directory",
serviceWrapperLogFile.getAbsolutePath());
}

ITriggerRouterService triggerRouterService = engine.getTriggerRouterService();
Expand Down Expand Up @@ -282,7 +281,7 @@ public static File createSnapshot(ISymmetricEngine engine) {
}

try {
File jarFile = new File(snapshotsDir, tmpDir.getName()
File jarFile = new File(getSnapshotDirectory(engine), tmpDir.getName()
+ ".zip");
JarBuilder builder = new JarBuilder(tmpDir, jarFile, new File[] { tmpDir }, Version.version());
builder.build();
Expand Down
Expand Up @@ -255,8 +255,6 @@ private ParameterConstants() {

public final static String SEQUENCE_TIMEOUT_MS = "sequence.timeout.ms";

public final static String SERVER_LOG_FILE = "server.log.file";

public final static String REST_API_ENABLED = "rest.api.enable";

public final static String REST_HEARTBEAT_ON_PULL = "rest.api.heartbeat.on.pull";
Expand Down
10 changes: 0 additions & 10 deletions symmetric-core/src/main/resources/symmetric-default.properties
Expand Up @@ -1253,16 +1253,6 @@ node.id.creator.script=
# Type: boolean
external.id.is.unique.enabled=true

# The name of the active log file. This is used by the system to locate the log file
# for analysis and trouble shooting. It is set to the default log file location for the
# standalone server. If deployed as a war file, you should update the value. Note that
# this property does not change the actual location the log file will be written. It just
# tells SymmetricDS where to find the log file.
#
# DatabaseOverridable: true
# Tags: general
server.log.file=logs/symmetric.log

# Enables the REST API
#
# DatabaseOverridable: true
Expand Down

0 comments on commit 086b8dd

Please sign in to comment.