|
@@ -1,36 +1,33 @@
|
|
-package com.fdkankan.scene.schedule;
|
|
|
|
|
|
+package com.fdkankan.scene;
|
|
|
|
|
|
|
|
|
|
-import cn.hutool.core.date.DateUnit;
|
|
|
|
-import cn.hutool.core.date.DateUtil;
|
|
|
|
-import cn.hutool.core.util.ObjectUtil;
|
|
|
|
import cn.hutool.system.SystemUtil;
|
|
import cn.hutool.system.SystemUtil;
|
|
import com.fdkankan.scene.config.FdkkLaserConfig;
|
|
import com.fdkankan.scene.config.FdkkLaserConfig;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.boot.ApplicationArguments;
|
|
|
|
+import org.springframework.boot.ApplicationRunner;
|
|
import org.springframework.boot.SpringApplication;
|
|
import org.springframework.boot.SpringApplication;
|
|
import org.springframework.context.ConfigurableApplicationContext;
|
|
import org.springframework.context.ConfigurableApplicationContext;
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
+import org.springframework.web.context.WebApplicationContext;
|
|
|
|
|
|
import javax.annotation.PostConstruct;
|
|
import javax.annotation.PostConstruct;
|
|
|
|
+import javax.annotation.Resource;
|
|
import java.io.BufferedReader;
|
|
import java.io.BufferedReader;
|
|
import java.io.InputStreamReader;
|
|
import java.io.InputStreamReader;
|
|
|
|
|
|
@Component
|
|
@Component
|
|
@Slf4j
|
|
@Slf4j
|
|
-public class AppListener {
|
|
|
|
|
|
+public class AppListener implements ApplicationRunner {
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
FdkkLaserConfig fdkkLaserConfig;
|
|
FdkkLaserConfig fdkkLaserConfig;
|
|
|
|
+ @Resource
|
|
|
|
+ private WebApplicationContext applicationContext;
|
|
|
|
|
|
- private final ConfigurableApplicationContext context;
|
|
|
|
-
|
|
|
|
- public AppListener(ConfigurableApplicationContext context) {
|
|
|
|
- this.context = context;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @PostConstruct
|
|
|
|
- public void init() {
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public void run(ApplicationArguments args) {
|
|
if (fdkkLaserConfig.getPid() <= 0) {
|
|
if (fdkkLaserConfig.getPid() <= 0) {
|
|
log.info("未配置 app.monitorPid,跳过 PID 监听。");
|
|
log.info("未配置 app.monitorPid,跳过 PID 监听。");
|
|
return;
|
|
return;
|
|
@@ -90,7 +87,7 @@ public class AppListener {
|
|
*/
|
|
*/
|
|
private void shutdownApplication() {
|
|
private void shutdownApplication() {
|
|
try {
|
|
try {
|
|
- SpringApplication.exit(context, () -> 0);
|
|
|
|
|
|
+ SpringApplication.exit(applicationContext, () -> 0);
|
|
} finally {
|
|
} finally {
|
|
System.exit(0);
|
|
System.exit(0);
|
|
}
|
|
}
|