reghao 5 tahun lalu
induk
melakukan
7de50eebd4

+ 10 - 0
common/src/main/java/cn/reghao/autodop/common/dockerc/unixdomain/HttpClient.java

@@ -1,5 +1,6 @@
 package cn.reghao.autodop.common.dockerc.unixdomain;
 
+import cn.reghao.autodop.common.utils.ExceptionUtil;
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
 import io.netty.handler.codec.http.*;
@@ -19,6 +20,15 @@ public class HttpClient {
         this.unixSocketClient = unixSocketClient;
     }
 
+    private FullHttpResponse errMsg(Exception e) {
+        FullHttpResponse httpResponse =
+                new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.INTERNAL_SERVER_ERROR);
+        ByteBuf errMsg = Unpooled.buffer(10);
+        errMsg.writeBytes(ExceptionUtil.errorMsg(e).getBytes(StandardCharsets.UTF_8));
+        httpResponse.replace(errMsg);
+        return httpResponse;
+    }
+
     public FullHttpResponse get(String uri, List<DockerHeader> headers) {
         FullHttpRequest request = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, uri);
         request.headers().set(HttpHeaderNames.HOST, "netty");

+ 0 - 3
common/src/main/java/cn/reghao/autodop/common/dockerc/unixdomain/UnixSocketClient.java

@@ -54,9 +54,6 @@ public class UnixSocketClient {
            if (future.isSuccess()) {
                log.info("已连接到 Unix Socket");
                channel = channelFuture.channel();
-           } else {
-               log.error("Unix Socket 连接失败...");
-               //throw new IOException("Unix Socket 连接失败...");
            }
         });
 

+ 1 - 1
dagent/src/main/java/cn/reghao/autodop/dagent/app/App.java

@@ -33,7 +33,7 @@ public class App {
                 try {
                     dockerAppServiceImpl.deploy(appDeployArgs);
                 } catch (DockerException e) {
-                    e.printStackTrace();
+                    log.error("docker 部署异常...");
                     return RpcResult.fail(ExceptionUtil.errorMsg(e));
                 }
             case zip:

+ 1 - 0
dagent/src/main/java/cn/reghao/autodop/dagent/utils/lifecycle/BeforeAppShutdown.java

@@ -21,6 +21,7 @@ public class BeforeAppShutdown implements ApplicationListener<ContextClosedEvent
 
     @Override
     public void onApplicationEvent(ContextClosedEvent event) {
+        // TODO 处理 mq 连接和定时任务
         log.warn("优雅关闭应用...");
     }
 }