‘liusuyi’
2023-12-14 2d7896ecd6bcafb4c0457a83ee254ff2006481ce
ard-work/src/main/java/com/ruoyi/cmd/startup.java
@@ -6,6 +6,7 @@
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.ApplicationContextInitializer;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.annotation.Order;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;
@@ -44,12 +45,6 @@
    String mediamtxName = "mediamtx.exe";
    @Value("${mediamtx.enabled}")
    Boolean mediamtxEnabled;
    //webrtc-streamer
    String webrtcName = "webrtc-streamer.exe";
    @Value("${webrtc.host}")
    String webrtcHost;
    @Value("${webrtc.enabled}")
    Boolean webrtcEnabled;
    //redis
    String redisName = "redis-server.exe";
@@ -77,6 +72,7 @@
    }
    @PostConstruct
    @Order(1)
    public void init() {
        if (minioEnabled) {
            log.info("初始化启动minio");
@@ -122,25 +118,6 @@
//            CmdUtils.commandStart(command);
            }
        }
        if (webrtcEnabled) {
            log.info("初始化启动webrtc-streamer");
            if (Platform.isWindows()) {
                String exePath = System.getProperty("user.dir") + File.separator + "server" + File.separator + "webrtc" + File.separator + webrtcName;
                List<String> cmd = new ArrayList<>();
                cmd.add(exePath);
                cmd.add("-H" + webrtcHost);
                cmd.add("-o");
                if (CmdUtils.isProcessRunning(webrtcName)) {
                    // 进程已经在运行,结束该进程
                    CmdUtils.stopProcess(webrtcName);
                }
                // 启动后台进程
                CmdUtils.commandStart(webrtcName, cmd, null);
                // 启动cmd窗口
//                String[] command = {"cmd", "/c", "start", exePath, "-H127.0.0.1:8000", "-o"};
//                CmdUtils.commandStart(command);
            }
        }
    }
    @PreDestroy
@@ -157,13 +134,6 @@
            if (CmdUtils.isProcessRunning(mediamtxName)) {
                // 进程已经在运行,结束该进程
                CmdUtils.stopProcess(mediamtxName);
            }
        }
        if (webrtcEnabled) {
            log.info("销毁webrtc-streamer");
            if (CmdUtils.isProcessRunning(webrtcName)) {
                // 进程已经在运行,结束该进程
                CmdUtils.stopProcess(webrtcName);
            }
        }
        if (true) {