Explorar o código

fix: timeout 300

ryanemax hai 2 meses
pai
achega
ab984a737f

+ 1 - 0
projects/textbook/src/app/comp-upload/provider-oss-aliyun.ts

@@ -18,6 +18,7 @@ export class ProvierOssAli{
             stsToken: result?.SecurityToken,
             // 填写Bucket名称。
             bucket: result?.ALI_OSS_BUCKET || "hep-textbook",
+            timeout:5000*1000
         });
     }
     constructor(){

+ 90 - 0
server/bak.8.140.nginx.conf

@@ -0,0 +1,90 @@
+
+server {
+    listen 80 default_server;
+    server_name _;
+
+
+    # 启动Gzip Json模式 ######################################################
+	gzip_http_version 1.0;  # gzip支持http协议 proxy 必须用
+    gzip  on;
+	gzip_vary on;
+	gzip_proxied       any;
+	gzip_static on;
+	gzip_comp_level  4;
+	gzip_min_length 256;
+    gzip_buffers     4 8k;
+    gzip_types       text/html text/plain application/javascript application/x-javascript text/css application/xml application/json;
+
+    client_header_timeout 300;
+    client_body_timeout 300;
+    keepalive_timeout 300;
+    proxy_connect_timeout 300;
+    proxy_send_timeout 300;
+    proxy_read_timeout 300;
+
+    location /api {
+        if ($request_method = 'OPTIONS') {
+            add_header 'Access-Control-Allow-Origin' '*';
+            add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
+            #
+            # Custom headers and headers various browsers *should* be OK with but aren't
+            #
+            add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
+            #
+            # Tell client that this pre-flight info is valid for 20 days
+            #
+            add_header 'Access-Control-Max-Age' 1728000;
+            add_header 'Content-Type' 'text/plain; charset=utf-8';
+            add_header 'Content-Length' 0;
+            return 204;
+        }
+        if ($request_method = 'POST') {
+            add_header 'Access-Control-Allow-Origin' '*' always;
+            add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
+            add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Access-Control-Allow-Origin' always;
+            add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range' always;
+        }
+        if ($request_method = 'GET') {
+            add_header 'Access-Control-Allow-Origin' '*' always;
+            add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
+            add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Access-Control-Allow-Origin' always;
+            add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range' always;
+        }
+
+        rewrite ^/(.*)$ /$1 break;
+        proxy_pass http://127.0.0.1:61336/api;
+    }
+
+    location /parse/{
+	proxy_read_timeout 300;
+        proxy_connect_timeout 300;
+        proxy_set_header Host $http_host;
+        proxy_set_header X-Real-IP $remote_addr;
+        proxy_set_header X-Scheme $scheme;
+        proxy_set_header X-Forwarded-Proto $scheme;
+        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+        proxy_pass http://127.0.0.1:61336/parse/;
+        proxy_redirect off;
+    }
+
+    location /docs/ {
+        proxy_read_timeout 300;
+        proxy_connect_timeout 300;
+    	client_body_buffer_size 500m;
+	client_max_body_size 1000m;
+
+        rewrite ^/docs/(.*)$ /$1 break;  # 去掉/docs/前缀
+
+        proxy_pass http://localhost:3000;  # 反向代理到本地的3000
+        proxy_set_header Host $host;
+        proxy_set_header X-Real-IP $remote_addr;
+        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+        proxy_set_header X-Forwarded-Proto $scheme;
+    }
+
+    root /var/www/edu-textbook/;
+    location /{
+        try_files $uri $uri/ /index.html?$query_string;
+    }
+
+}

+ 1 - 0
server/cloud/tbook/func-tbook-export.js

@@ -36,6 +36,7 @@ const squareCheck = [`□`,String.fromCharCode(0xFE)];
 
     // 全新导出,每次都重新导出
     app.post("/parse/api/tbook/export",async (request,res)=>{
+        request.setTimeout(500*1000);
         let processId = request.body.processId;
         let bookList = request.body.bookList;
         console.log(request.body)

+ 3 - 2
server/cloud/tbook/test/test-export.js

@@ -51,8 +51,9 @@ async function main(){
         // console.log(await exportProcessReportDocs(null,["z7yhFusOns"])) 
         // console.log(await exportProcessReportDocs(null,["ybzJWkXqQG"])) 
         // console.log(await exportProcessReportDocs(null,["4UAwQ4nc5A"])) 
-        console.log(await exportProcessReportDocs(null,["ybzJWkXqQG"])) 
-        
+        // console.log(await exportProcessReportDocs(null,["ybzJWkXqQG"])) 
+        // console.log(await exportProcessReportDocs(null,["PghuiugQpb"])) 
+        console.log(await exportProcessReportDocs(null,["pdo6maunud","iWBI0FMTAS","Faw2Hl4qTf","lAG4JpaAIW","1aRyDbVyUu","GVNtZWdm50","5dq8TYCGfu","YkLYd4rv2v","889gBLs62l","fWTphlIAZu","DrHtcRrgXe","n6TxQZ0aOp","oV9W7FbyPj","sY1jZXS5rF","uvmtqWdMlM","rPaRkc0S3I","ikQXhMJPw7","ll0kl2RCBk","QCdJfwlBCh","F7aE1ACEgd","CcMa620Q5J","tk4zR6RbQN","6GLa6Po9p8","TbwoGVrSlR","xNDkRbGDP5","qg1ITwStRR","xHfG3po2yC","Tg7ndNBZvz","Hi1C6G43TM","mwCcj1VDrc"])) 
         
         // console.log(await exportProcessReportDocs(null,["3wJSkW9HNV"]))
         // console.log(await exportProcessReportDocs(null,["tHhfIDBkhf"]))

+ 1 - 1
server/deploy.sh

@@ -1,5 +1,5 @@
 #!/bin/bash
-npx vite build
+npx vite build # node dist/server/server.js
 # 开发主机(开发环境服务器 有SSH权限至生产环境)
 DEV_HOST=root@dbo.fmode.cn
 # 生产主机(生产环境服务器)

+ 1 - 0
server/lib/docs/index.js

@@ -56,6 +56,7 @@ export async function uploadFileToOSS(filePath,uniqueId){
         accessKeySecret: ALI_OSS_ACCESS_KEY_SECRET,
         // 填写Bucket名称。
         bucket: ALI_OSS_BUCKET || "hep-textbook",
+        timeout:5000*1000
     });
 
     let now = new Date();

+ 2 - 1
server/server.js

@@ -173,6 +173,8 @@ async function initParseAndDatabase(){
     /**
      * Listen on provided port, on all network interfaces.
      */
+    // console.log("setTimeout",app?.setTimeout)
+    // app?.setTimeout&&app.setTimeout(1000*300)
     app.listen(global.parseConfig?.port, async function() {
       console.log('微服务已运行,端口 ' + global.parseConfig?.port + '.');
       // 迁移数据范式 Schemas
@@ -193,7 +195,6 @@ async function initParseAndDatabase(){
       defineTbookISBN();
       defineTbookExportReport(app);
     });
-    app?.setTimeout&&app.setTimeout(1000*300)
  
     console.log("正在启动管理看板...")
     console.log("浏览器管理看板:","http://localhost:61337/dashboard")