fix contract client missing log bugs

This commit is contained in:
CaiHQ 2023-06-09 18:20:47 +08:00
parent 630bb2eb7e
commit 6cd99cf17a
3 changed files with 9 additions and 7 deletions

View File

@ -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<ProcessBuilder> 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()));

View File

@ -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);
}

View File

@ -360,11 +360,9 @@ public class ContractStatusRecorder extends StatusRecorder<ContractMeta> {
// 可增加一个判断如果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);