浏览代码

Merge pull request #658 from Kingsuperyzy/master

运维管理模块 websocket 异常修复
AllData创始人 1 年之前
父节点
当前提交
a584b4a674

+ 7 - 0
studio/config/src/main/resources/config/gateway-dev.yml

@@ -27,6 +27,13 @@ spring:
               args:
                 name: systemHystrix
                 fallbackUri: forward:/fallback
+        # 系统基础设置中心
+        - id: service-system
+          uri: lb:ws://service-system
+          predicates:
+            - Path=/ws/**
+          filters:
+            - StripPrefix=1
         # 邮件中心
         - id: service-email
           uri: lb://service-email

+ 1 - 1
studio/micro-ui/src/views/mnt/deploy/deploy.vue

@@ -147,7 +147,7 @@ export default {
       })
     },
     initWebSocket() {
-      const wsUri = (process.env.VUE_APP_WS_API === '/' ? '/' : (process.env.VUE_APP_WS_API + '/')) + 'webSocket/deploy'
+      const wsUri = (process.env.VUE_APP_WS_API === '/' ? '/' : (process.env.VUE_APP_WS_API + '/')) + 'ws/webSocket/deploy'
       this.websock = new WebSocket(wsUri)
       this.websock.onerror = this.webSocketOnError
       this.websock.onmessage = this.webSocketOnMessage

+ 5 - 0
studio/modules/system-service-parent/system-service/pom.xml

@@ -20,6 +20,11 @@
             <artifactId>DynamicDataSource</artifactId>
             <version>1.3.2</version>
         </dependency>
+
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-websocket</artifactId>
+        </dependency>
         <!-- 获取系统信息 -->
         <dependency>
             <groupId>com.github.oshi</groupId>

+ 13 - 0
studio/modules/system-service-parent/system-service/src/main/java/com/platform/config/WebSocketConfig.java

@@ -1,6 +1,8 @@
 package com.platform.config;
 
+import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
+import org.springframework.web.socket.server.standard.ServerEndpointExporter;
 
 /**
  * @author AllDataDC
@@ -9,4 +11,15 @@ import org.springframework.context.annotation.Configuration;
 @Configuration
 public class WebSocketConfig {
 
+    /**
+     * ServerEndpointExporter 作用
+     *
+     * 这个Bean会自动注册使用@ServerEndpoint注解声明的websocket endpoint
+     *
+     * @return
+     */
+    @Bean
+    public ServerEndpointExporter serverEndpointExporter() {
+        return new ServerEndpointExporter();
+    }
 }