From d06e5bcaac5610ab8ad12b72c5441c7472a2f4b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=93=B8=E6=B8=8A=20ICE-GL-ZY001?= Date: Tue, 26 May 2026 02:45:38 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20push-heartbeat=20=E6=94=B9=E7=94=A8HTTPS?= =?UTF-8?q?+=E5=9F=9F=E5=90=8D=20guanghulab.com:443?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/deploy-push-heartbeat.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/deploy-push-heartbeat.js b/scripts/deploy-push-heartbeat.js index dddaebb..ae439de 100644 --- a/scripts/deploy-push-heartbeat.js +++ b/scripts/deploy-push-heartbeat.js @@ -13,8 +13,8 @@ const SERVERS = [ { code: "BS-SH-005", name: "上海·国内节点", ip: "124.223.10.33", key: "zy_gtw_b1045de5ddfd7832e3c53349d9c896f054b85a4a9ece22f9", port: 3910 }, ]; -const MASTER_HOST = "43.139.217.141"; -const MASTER_PORT = 80; +const MASTER_HOST = "guanghulab.com"; +const MASTER_PORT = 443; const MASTER_PATH = "/console/api/heartbeat"; function gkExec(srv, cmd, timeoutMs) { @@ -39,10 +39,10 @@ function gkExec(srv, cmd, timeoutMs) { // 推送脚本模板 — 通过nginx /console/ → console-server:3920 function pushScript(code, name, key) { return ` -const http=require("http"),os=require("os"); +const https=require("https"),os=require("os"); const HOST="${MASTER_HOST}",PORT=${MASTER_PORT},PATH="${MASTER_PATH}",CODE="${code}",NAME="${name}",KEY="${key}"; function hw(){const c=os.cpus().length,l=os.loadavg(),t=os.totalmem(),f=os.freemem();return{cpu_cores:c,cpu_load:parseFloat(l[0].toFixed(2)),mem_total_mb:Math.floor(t/1048576),mem_used_mb:Math.floor((t-f)/1048576),mem_used_pct:parseFloat(((t-f)/t*100).toFixed(1)),uptime_h:Math.floor(os.uptime()/3600),hostname:os.hostname()}} -function post(d){return new Promise(r=>{const p=JSON.stringify(d),o={hostname:HOST,port:PORT,path:PATH,method:"POST",headers:{"Content-Type":"application/json","Content-Length":Buffer.byteLength(p),"X-Server-Code":CODE,"X-Server-Key":KEY},timeout:8000};const q=http.request(o,res=>{let b="";res.on("data",c=>b+=c);res.on("end",()=>r(res.statusCode===200))});q.on("error",()=>r(false));q.on("timeout",()=>{q.destroy();r(false)});q.write(p);q.end()})} +function post(d){return new Promise(r=>{const p=JSON.stringify(d),o={hostname:HOST,port:PORT,path:PATH,method:"POST",headers:{"Content-Type":"application/json","Content-Length":Buffer.byteLength(p),"X-Server-Code":CODE,"X-Server-Key":KEY},timeout:8000,rejectUnauthorized:false};const q=https.request(o,res=>{let b="";res.on("data",c=>b+=c);res.on("end",()=>r(res.statusCode===200))});q.on("error",()=>r(false));q.on("timeout",()=>{q.destroy();r(false)});q.write(p);q.end()})} (async()=>{const d={server_code:CODE,server_name:NAME,timestamp:new Date().toISOString(),hardware:hw()};const ok=await post(d);console.log(new Date().toISOString()+" "+(ok?"OK":"FAIL"))})(); `.trim(); }