Browse Source

REPORT-73396【设计器环境监测】删除fine-decision-11.0,触发的是重置finedb

通过守护进程,处理一下设计器启动不了且没有直接报错的场景。
(mac 下还是有问题,守护进程不支持 mac
feature/x
Harrison 2 years ago
parent
commit
4d01785829
  1. 13
      designer-base/src/main/java/com/fr/env/detect/EnvDetectorCenter.java
  2. 66
      designer-base/src/main/java/com/fr/exit/DesignerExiter.java
  3. 6
      designer-realize/src/main/java/com/fr/start/DesignerSubListener.java
  4. 3
      designer-realize/src/main/java/com/fr/start/DesignerSuperListener.java

13
designer-base/src/main/java/com/fr/env/detect/EnvDetectorCenter.java vendored

@ -54,7 +54,6 @@ public class EnvDetectorCenter {
} }
}; };
private final Listener<Null> START_UP_COMPLETE_LISTENER = new Listener<Null>() { private final Listener<Null> START_UP_COMPLETE_LISTENER = new Listener<Null>() {
@Override @Override
@ -196,6 +195,18 @@ public class EnvDetectorCenter {
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
/**
* 预期外的终止
*
* @return 检测结果
*/
public List<DetectorResult> terminateUnexpectedly() {
Stream<DetectorResult> resultStream = DetectorBridge.getInstance().detect();
return resultStream
.filter((e) -> e.getStatus() == DetectorStatus.EXCEPTION)
.collect(Collectors.toList());
}
private void listen() { private void listen() {

66
designer-base/src/main/java/com/fr/exit/DesignerExiter.java

@ -17,7 +17,9 @@ import com.fr.log.FineLoggerFactory;
import com.fr.process.engine.core.FineProcessContext; import com.fr.process.engine.core.FineProcessContext;
import com.fr.process.engine.core.FineProcessEngineEvent; import com.fr.process.engine.core.FineProcessEngineEvent;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.function.Supplier;
/** /**
* @author hades * @author hades
@ -32,16 +34,43 @@ public class DesignerExiter {
return INSTANCE; return INSTANCE;
} }
/**
* 预期外的退出
* 首先检测是否有检测到的异常如果没有则运行默认行为
*
* @param defaultAction 默认行为
*/
public void exitUnexpectedly(Runnable defaultAction) {
// 尝试进行检测
List<DetectorResult> results = runAndGet(() -> EnvDetectorCenter.getInstance().terminateUnexpectedly(), ArrayList::new);
try {
if (!Collections.isEmpty(results)) {
showNewExitDialog(results);
}
} finally {
// 正常的话上面会直接退出, system.exit(0)
// 只有异常,或者不命中,才会走到这里
defaultAction.run();
}
}
public void exit(Throwable throwable) { public void exit(Throwable throwable) {
FineLoggerFactory.getLogger().error(throwable.getMessage(), throwable); doThrowableAction(() -> {
FineLoggerFactory.getLogger().error(throwable.getMessage(), throwable);
}, () -> {
throwable.printStackTrace(System.err);
});
StartErrorMessageCollector.getInstance().record(DesignerErrorMessage.UNEXCEPTED_START_FAILED.getId(), doThrowableAction(() -> {
DesignerErrorMessage.UNEXCEPTED_START_FAILED.getMessage(), StartErrorMessageCollector.getInstance().record(DesignerErrorMessage.UNEXCEPTED_START_FAILED.getId(),
throwable.getMessage()); DesignerErrorMessage.UNEXCEPTED_START_FAILED.getMessage(),
throwable.getMessage());
});
// 尝试进行检测 // 尝试进行检测
List<DetectorResult> results = EnvDetectorCenter.getInstance().terminate(throwable); List<DetectorResult> results = runAndGet(() -> EnvDetectorCenter.getInstance().terminate(throwable), ArrayList::new);
if (Collections.isEmpty(results)) { if (Collections.isEmpty(results)) {
// 为空,则 // 为空,则
@ -89,4 +118,31 @@ public class DesignerExiter {
private void beforeExit() { private void beforeExit() {
DesignerWorkspaceGenerator.stop(); DesignerWorkspaceGenerator.stop();
} }
/* 忽视异常的调用方法 */
private void doThrowableAction(Runnable runnable) {
doThrowableAction(runnable, null);
}
private void doThrowableAction(Runnable runnable, Runnable defaultRunnable) {
try {
runnable.run();
} catch (Throwable ignore) {
if (defaultRunnable != null) {
defaultRunnable.run();
}
}
}
private <T> T runAndGet(Supplier<T> supplier, Supplier<T> defaultCallable) {
try {
return supplier.get();
} catch (Exception ignore) {
return defaultCallable.get();
}
}
} }

6
designer-realize/src/main/java/com/fr/start/DesignerSubListener.java

@ -4,6 +4,7 @@ import com.fr.design.mainframe.DesignerContext;
import com.fr.event.Event; import com.fr.event.Event;
import com.fr.event.Listener; import com.fr.event.Listener;
import com.fr.event.Null; import com.fr.event.Null;
import com.fr.exit.DesignerExiter;
import com.fr.process.engine.core.CarryMessageEvent; import com.fr.process.engine.core.CarryMessageEvent;
import com.fr.process.engine.core.FineProcessContext; import com.fr.process.engine.core.FineProcessContext;
import com.fr.process.engine.core.FineProcessEngineEvent; import com.fr.process.engine.core.FineProcessEngineEvent;
@ -31,7 +32,10 @@ public class DesignerSubListener {
@Override @Override
public void on(Event event, Null param) { public void on(Event event, Null param) {
if (DesignerContext.getDesignerFrame() == null || !DesignerContext.getDesignerFrame().isShowing()) { if (DesignerContext.getDesignerFrame() == null || !DesignerContext.getDesignerFrame().isShowing()) {
FineProcessContext.getParentPipe().fire(new CarryMessageEvent(DesignerProcessType.INSTANCE.obtain()));
DesignerExiter.getInstance().exitUnexpectedly(() -> {
FineProcessContext.getParentPipe().fire(new CarryMessageEvent(DesignerProcessType.INSTANCE.obtain()));
});
} }
} }
}); });

3
designer-realize/src/main/java/com/fr/start/DesignerSuperListener.java

@ -31,7 +31,7 @@ import java.util.concurrent.TimeUnit;
public class DesignerSuperListener { public class DesignerSuperListener {
private static final DesignerSuperListener INSTANCE = new DesignerSuperListener(); private static final DesignerSuperListener INSTANCE = new DesignerSuperListener();
private static final int ONCE_DELAY = 180; private static final int ONCE_DELAY = 30;
private static final int FIXED_DELAY = 0; private static final int FIXED_DELAY = 0;
private static final int FIXED_FREQ = 2; private static final int FIXED_FREQ = 2;
@ -95,6 +95,7 @@ public class DesignerSuperListener {
public void run() { public void run() {
cancel = true; cancel = true;
ProcessEventPipe pipe = process.getPipe(); ProcessEventPipe pipe = process.getPipe();
// 确认设计器是否启动完成
pipe.fire(FineProcessEngineEvent.READY); pipe.fire(FineProcessEngineEvent.READY);
if (StringUtils.isNotEmpty(pipe.info())) { if (StringUtils.isNotEmpty(pipe.info())) {
frameReport(); frameReport();

Loading…
Cancel
Save