diff --git a/src/main/java/org/bdware/sc/ContractClient.java b/src/main/java/org/bdware/sc/ContractClient.java index a105b50..e7c299d 100644 --- a/src/main/java/org/bdware/sc/ContractClient.java +++ b/src/main/java/org/bdware/sc/ContractClient.java @@ -253,10 +253,11 @@ public class ContractClient { if (contractMeta.contract.getRemoteDebugPort() != 0) { pbParameters.add(String.format("-agentlib:jdwp=transport=dt_socket,address=%d,server=y,suspend=n", contractMeta.contract.getRemoteDebugPort())); } + File classParent = new File(classpath).getParentFile(); if (contractMeta.contract.isDebug()) { - pbParameters.add("-Dlog4j.configurationFile=./log4j2.debug.properties"); + pbParameters.add("-Dlog4j.configurationFile=" + new File(classParent, "log4j2.debug.properties").getAbsolutePath()); } else { - pbParameters.add("-Dlog4j.configurationFile=./log4j2.properties"); + pbParameters.add("-Dlog4j.configurationFile=" + new File(classParent, "log4j2.properties").getAbsolutePath()); } pbParameters.add("-jar"); pbParameters.add(classpath); @@ -269,6 +270,7 @@ public class ContractClient { pbParameters.toArray(result); Constructor pbc = ProcessBuilder.class.getDeclaredConstructor(String[].class); builder = pbc.newInstance(new Object[]{result}); + File directory = new File("./"); LOGGER.debug("[CMD] path: " + directory.getAbsolutePath()); LOGGER.debug(JsonUtil.toPrettyJson(builder.command())); diff --git a/src/main/java/org/bdware/sc/ContractManager.java b/src/main/java/org/bdware/sc/ContractManager.java index 04c8a56..3f1c9b0 100644 --- a/src/main/java/org/bdware/sc/ContractManager.java +++ b/src/main/java/org/bdware/sc/ContractManager.java @@ -973,6 +973,7 @@ public class ContractManager { } return null; } + private void setContractStateful(Contract c) { ContractManifest cm = YJSPacker.getManifest(c.getScriptStr()); if (cm != null && cm.stateful != null && cm.stateful.equals("false")) { @@ -1770,6 +1771,7 @@ public class ContractManager { public String loadMemory(ContractClient client, String path) { if (client == null) return "no such contract client"; + if (path == null || path.length() == 0) return "no such memory file"; addLocalContractLog("loadMemory", client.contractMeta); return client.get.syncGet("", "loadMemory", path); } diff --git a/src/main/java/org/bdware/sc/ContractStatusRecorder.java b/src/main/java/org/bdware/sc/ContractStatusRecorder.java index f80aee9..be1b26e 100644 --- a/src/main/java/org/bdware/sc/ContractStatusRecorder.java +++ b/src/main/java/org/bdware/sc/ContractStatusRecorder.java @@ -360,11 +360,9 @@ public class ContractStatusRecorder extends StatusRecorder { // 可增加一个判断,如果hanged朋manifest里是加载memory,这里就不再加载了。 ContractClient client = id2ContractClient.get(meta.getID()); if (preStatus == ContractStatusEnum.HANGED) { - - ContractManager.instance.loadMemory( - client, ContractManager.instance.findNewestMemory(meta.name)); - - + String memory = ContractManager.instance.findNewestMemory(meta.name); + if (memory != null) + ContractManager.instance.loadMemory(client, memory); } client.contractMeta.setStatus(ContractStatusEnum.RUNNING); updateValue(client.contractMeta);