|
@@ -2,6 +2,7 @@ package com.utic.its.moct.utic.server;
|
|
|
|
|
|
import com.its.common.spring.SpringUtils;
|
|
import com.its.common.spring.SpringUtils;
|
|
import com.utic.its.common.repository.ApplicationRepository;
|
|
import com.utic.its.common.repository.ApplicationRepository;
|
|
|
|
+import com.utic.its.moct.utic.server.config.HaClusterConfig;
|
|
import com.utic.its.moct.utic.server.process.DbmsDataProcessService;
|
|
import com.utic.its.moct.utic.server.process.DbmsDataProcessService;
|
|
import com.utic.its.moct.utic.server.process.PacketDataProcessService;
|
|
import com.utic.its.moct.utic.server.process.PacketDataProcessService;
|
|
import com.utic.its.moct.utic.server.repository.MoctUticServerRepository;
|
|
import com.utic.its.moct.utic.server.repository.MoctUticServerRepository;
|
|
@@ -82,10 +83,13 @@ public class MoctUticServerApplication implements CommandLineRunner, Application
|
|
ItsAsnCommServerService itsAsnCommServerService = SpringUtils.getBean(ItsAsnCommServerService.class);
|
|
ItsAsnCommServerService itsAsnCommServerService = SpringUtils.getBean(ItsAsnCommServerService.class);
|
|
itsAsnCommServerService.run();
|
|
itsAsnCommServerService.run();
|
|
|
|
|
|
- HaClusterMasterService haClusterMasterService = SpringUtils.getBean(HaClusterMasterService.class);
|
|
|
|
- haClusterMasterService.start();
|
|
|
|
- HaClusterSlaveService haClusterSlaveService = SpringUtils.getBean(HaClusterSlaveService.class);
|
|
|
|
- haClusterSlaveService.start();
|
|
|
|
|
|
+ HaClusterConfig haClusterConfig = SpringUtils.getBean(HaClusterConfig.class);
|
|
|
|
+ if (haClusterConfig.isEnabled()) {
|
|
|
|
+ HaClusterMasterService haClusterMasterService = SpringUtils.getBean(HaClusterMasterService.class);
|
|
|
|
+ haClusterMasterService.start();
|
|
|
|
+ HaClusterSlaveService haClusterSlaveService = SpringUtils.getBean(HaClusterSlaveService.class);
|
|
|
|
+ haClusterSlaveService.start();
|
|
|
|
+ }
|
|
|
|
|
|
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
|
|
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
|
|
log.error("Runtime thread: on shutdown hook.");
|
|
log.error("Runtime thread: on shutdown hook.");
|
|
@@ -143,6 +147,15 @@ public class MoctUticServerApplication implements CommandLineRunner, Application
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
log.error("** clusterMasterService.shutdown: {}", e.getMessage());
|
|
log.error("** clusterMasterService.shutdown: {}", e.getMessage());
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+ HaClusterSlaveService haClusterSlaveService = SpringUtils.getBean(HaClusterSlaveService.class);
|
|
|
|
+ if (haClusterSlaveService != null) {
|
|
|
|
+ haClusterSlaveService.shutdown();
|
|
|
|
+ }
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ log.error("** haClusterSlaveService.shutdown: {}", e.getMessage());
|
|
|
|
+ }
|
|
try {
|
|
try {
|
|
SpringApplication.exit(SpringUtils.getApplicationContext());
|
|
SpringApplication.exit(SpringUtils.getApplicationContext());
|
|
System.exit(0);
|
|
System.exit(0);
|