MCPcopy Create free account
hub / github.com/e2wugui/zeze / run

Method run

ZezeJava/ZezeJava/src/main/java/Zeze/Services/Daemon.java:300–332  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

298 }
299
300 @Override
301 public void run() {
302 try {
303 while (running) {
304 var bb = copyMMap();
305 var now = System.currentTimeMillis();
306 for (int i = 0; i < globalConfigs.length(); ++i) {
307 var activeTime = bb.ReadLong8();
308 var config = getConfig(i);
309 if (config == null)
310 continue; // skip not ready global
311
312 var idle = now - activeTime;
313 if (idle > config.serverReleaseTimeout) {
314 logger.info("destroySubprocess {} - {} > {}", now, activeTime, config.serverReleaseTimeout);
315 destroySubprocess();
316 // daemon main will restart subprocess!
317 } else if (idle > config.serverDaemonTimeout) {
318 logger.info("sendCommand Release-{} {} - {} > {}", i, now, activeTime, config.serverDaemonTimeout);
319 // 在Server执行Release期间,命令可能重复发送。
320 // 重复命令的处理由Server完成,
321 // 这里重发也是需要的,刚好解决Udp不可靠性。
322 sendCommand(udpSocket, peerSocketAddress, new Release(i));
323 }
324 //noinspection BusyWait
325 Thread.sleep(1000);
326 }
327 }
328 } catch (Throwable ex) { // print stacktrace.
329 logger.fatal("Monitor.run", ex);
330 fatalExit();
331 }
332 }
333
334 public void stopAndJoin() throws InterruptedException {
335 running = false;

Callers

nothing calls this directly

Calls 7

copyMMapMethod · 0.95
getConfigMethod · 0.95
destroySubprocessMethod · 0.80
sendCommandMethod · 0.80
fatalExitMethod · 0.80
ReadLong8Method · 0.65
sleepMethod · 0.45

Tested by

no test coverage detected