Browse Source

Dev showTransferProgress

tsurumure 1 tháng trước cách đây
mục cha
commit
f8defa1a90

+ 0 - 0
configuration/nginx/conf.d/ai.api.conf → configuration/nginx/conf.d/ai.daogu.api.conf


+ 0 - 0
configuration/nginx/conf.d/ai.manage.conf → configuration/nginx/conf.d/ai.daogu.manage.conf


+ 13 - 0
configuration/nginx/conf.d/comfyui_output.conf

@@ -0,0 +1,13 @@
+# 在 ComfyUI 主机中配置,将 9999 端口暴露出来
+server {
+    listen 9999;
+    server_name _;
+    location /8000/ { alias /mnt/nvme0n1/ComfyUI/ComfyUI_0/output/; }
+    location /8001/ { alias /mnt/nvme0n1/ComfyUI/ComfyUI_1/output/; }
+    location /8002/ { alias /mnt/nvme0n1/ComfyUI/ComfyUI_2/output/; }
+    location /8003/ { alias /mnt/nvme0n1/ComfyUI/ComfyUI_3/output/; }
+    location /8004/ { alias /mnt/nvme0n1/ComfyUI/ComfyUI_4/output/; }
+    location /8005/ { alias /mnt/nvme0n1/ComfyUI/ComfyUI_5/output/; }
+    location /8006/ { alias /mnt/nvme0n1/ComfyUI/ComfyUI_6/output/; }
+    location /8007/ { alias /mnt/nvme0n1/ComfyUI/ComfyUI_7/output/; }
+}

+ 51 - 0
configuration/nginx/conf.d/o.daogu.conf

@@ -0,0 +1,51 @@
+server {
+    listen          80;
+    server_name     o.daogu.ai;
+
+    location ^~ /.well-known/acme-challenge/ {
+        root /home/webroot;
+        allow all;
+    }
+
+    location / {
+        proxy_pass http://127.0.0.1:9999;
+        proxy_http_version 1.1;
+        proxy_connect_timeout 4s;
+        proxy_read_timeout 60s;
+        proxy_send_timeout 12s;
+        proxy_set_header Upgrade $http_upgrade;
+        proxy_set_header Connection "upgrade";
+        proxy_set_header X-Real-IP $remote_addr;
+        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+        proxy_set_header Host $http_host;
+        proxy_set_header X-NginX-Proxy true;
+        proxy_redirect off;
+    }
+}
+
+#server {
+#    listen       443 ssl;
+#    server_name  o.daogu.ai;
+#
+#    ssl_certificate      /root/.acme.sh/o.daogu.ai/fullchain.cer;
+#    ssl_certificate_key  /root/.acme.sh/o.daogu.ai/o.daogu.ai.key;
+#    ssl_session_cache    shared:SSL:1m;
+#    ssl_session_timeout  5m;
+#    ssl_ciphers  HIGH:!aNULL:!MD5;
+#    ssl_prefer_server_ciphers  on;
+#
+#    location / {
+#        proxy_pass http://127.0.0.1:9999;
+#        proxy_http_version 1.1;
+#        proxy_connect_timeout 4s;
+#        proxy_read_timeout 60s;
+#        proxy_send_timeout 12s;
+#        proxy_set_header Upgrade $http_upgrade;
+#        proxy_set_header Connection "upgrade";
+#        proxy_set_header X-Real-IP $remote_addr;
+#        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+#        proxy_set_header Host $http_host;
+#        proxy_set_header X-NginX-Proxy true;
+#        proxy_redirect off;
+#    }
+#}

+ 24 - 14
src/main/java/com/backendsys/modules/sdk/comfyui/service/impl/ComfyUISocketServiceImpl.java

@@ -34,6 +34,7 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
+import java.util.concurrent.CompletableFuture;
 import java.util.concurrent.ConcurrentHashMap;
 
 @Service
@@ -167,8 +168,12 @@ public class ComfyUISocketServiceImpl implements ComfyUISocketService {
                                         for (int i = 0; i < images.size(); i++) {
                                             JSONObject image = images.getJSONObject(i);
                                             String filename = image.getStr("filename");
-                                            String filepath = "http://" + COMFYUI_HOST + ":" + port + "/api/view?filename=" + filename;
-                                            String filepath_with_token = filepath + "&token=" + COMFYUI_TOKEN;
+
+                                            // ComfyUI + Nginx 输出域名转发
+//                                            String filepath = "http://" + COMFYUI_HOST + ":" + port + "/api/view?filename=" + filename;
+//                                            String filepath_with_token = filepath + "&token=" + COMFYUI_TOKEN;
+
+                                            String filepath = "http://o.daogu.ai/" + port + "/" + filename;
 
                                             // -- [图片转存储存桶] -------------------------------------
                                             SysFileResult result = new SysFileResult();
@@ -176,25 +181,30 @@ public class ComfyUISocketServiceImpl implements ComfyUISocketService {
 
                                             // target: 上传目标 (-1:本地, 1:腾讯云, 2:阿里云, 3.抖音云)
                                             if (UPLOAD_TARGET == 1) {
-                                                result = tencentCosService.urlToCOS(filepath_with_token);
+                                                result = tencentCosService.urlToCOS(filepath, "png");
                                             }
                                             if (UPLOAD_TARGET == 3) {
-                                                result = douyinTosService.urlToTOS(filepath_with_token);
+                                                result = douyinTosService.urlToTOS(filepath, "png");
                                             }
-                                            System.out.println("filepath_with_token = " + filepath_with_token);
                                             System.out.println("result = " + result);
 
                                             // -- [记录到生成图片记录表] --------------------------------
                                             if (params != null) {
-                                                Long drama_project_storyboard_id = Convert.toLong(params.get("drama_project_storyboard_id"));
-                                                String prompt_id = Convert.toStr(dataChildren.get("prompt_id"));
-                                                if (drama_project_storyboard_id != null) {
-                                                    entity.setDrama_project_storyboard_id(drama_project_storyboard_id);
-                                                    entity.setPrompt_id(prompt_id);
-                                                    entity.setUrl_origin(filepath);
-                                                    System.out.println("crtGenerateImage entity = " + entity);
-                                                    crtGenerateImageDao.insert(entity);
-                                                }
+
+                                                // 创建一个 CompletableFuture 来执行异步任务
+                                                CompletableFuture.runAsync(() -> {
+
+                                                    Long drama_project_storyboard_id = Convert.toLong(params.get("drama_project_storyboard_id"));
+                                                    String prompt_id = Convert.toStr(dataChildren.get("prompt_id"));
+                                                    if (drama_project_storyboard_id != null) {
+                                                        entity.setDrama_project_storyboard_id(drama_project_storyboard_id);
+                                                        entity.setPrompt_id(prompt_id);
+                                                        entity.setUrl_origin(filepath);
+                                                        crtGenerateImageDao.insert(entity);
+                                                    }
+
+                                                });
+
                                             }
                                             // ------------------------------------------------------
 

+ 16 - 1
src/main/java/com/backendsys/modules/sdk/tencentcloud/cos/service/impl/TencentCosServiceImpl.java

@@ -85,8 +85,23 @@ public class TencentCosServiceImpl implements TencentCosService {
     // [腾讯云COS][高级接口] 获取进度函数
     private void showTransferProgress(String filename, Transfer transfer) {
 
+
+
+
+
+
+
+        // 为什么 urlToCos 这里拿不到 Token?
+
         Long user_id = SecurityUtil.getUserId();
 
+
+
+
+
+
+
+
         // [SSE] 进度回传
         Progress progress = new Progress();
         progress.setState("init");
@@ -393,7 +408,7 @@ public class TencentCosServiceImpl implements TencentCosService {
             // 高级上传
             TransferManager transferManager = TencentCosUtil.createTransferManager(cosClient);
             Upload upload = transferManager.upload(putObjectRequest);   // 返回一个异步结果Upload
-            showTransferProgress(object_filename, upload);                     // 查询上传进度,直到上传结束
+            showTransferProgress(object_filename, upload);              // 查询上传进度,直到上传结束
             UploadResult uploadResult = upload.waitForUploadResult();   // 捕获可能出现的异常
 
             SysFileResult result = new SysFileResult();