@oxiaom/adoremix 1.0.63 → 1.0.64

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/tts-deps.js +33 -9
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oxiaom/adoremix",
3
- "version": "1.0.63",
3
+ "version": "1.0.64",
4
4
  "description": "AdoreMix broadcast server - cross-platform installer, runner and service manager",
5
5
  "bin": {
6
6
  "adoremix": "./bin/adoremix.js"
package/src/tts-deps.js CHANGED
@@ -249,15 +249,16 @@ function checkDeps(workdir, providerName, cfg) {
249
249
  issues.push({ severity: 'error', category: 'service', msg: `audio8_base_url 无效: ${audio8BaseUrl}(需 config.ini [TTS] audio8_base_url 配置,如 http://127.0.0.1:8024)`, autoFixable: false });
250
250
  }
251
251
  if (u) {
252
- try {
253
- // http 回调是异步的,直接 push issue 会丢——用 execSync curl 同步探测
254
- const out = execSync(`curl -s -o /dev/null -w "%{http_code}" --max-time 3 "${audio8BaseUrl.replace(/\/+$/, '')}/api/health"`,
255
- { shell: '/bin/bash', encoding: 'utf8', stdio: ['pipe', 'pipe', 'pipe'] }).trim();
256
- if (out !== '200') {
257
- issues.push({ severity: 'error', category: 'service', msg: `Audio8 服务异常:${audio8BaseUrl}/api/health 返回 HTTP ${out}。检查 systemctl status audio8-tts(本机部署时)或确认 audio8_base_url 指向的远程服务可达。`, autoFixable: false });
258
- }
259
- } catch (e) {
260
- issues.push({ severity: 'error', category: 'service', msg: `Audio8 服务不可达(${audio8BaseUrl}):${String(e.message).split('\n')[0]}。本机部署用 systemctl restart audio8-tts 拉起;远程部署确认网络可达。`, autoFixable: false });
252
+ // 同步 HTTP 探测(不能 execSync curl: Windows 无 curl/bash;也不能 async 回调:
253
+ // checkDeps 是同步函数,回调里的 push 会丢)。spawn curl 带平台回退。
254
+ const statusCode = httpStatusSync(u, '/api/health', 3000);
255
+ if (statusCode === -1) {
256
+ // 平台无任何 HTTP 探测工具,跳过(不阻断安装)
257
+ } else if (statusCode !== 200) {
258
+ const detail = statusCode === null
259
+ ? '无响应/连接失败'
260
+ : `HTTP ${statusCode}`;
261
+ issues.push({ severity: 'error', category: 'service', msg: `Audio8 服务不可达(${audio8BaseUrl}):${detail}。本机部署用 systemctl restart audio8-tts 拉起;远程部署确认网络可达。`, autoFixable: false });
261
262
  }
262
263
  }
263
264
  }
@@ -265,6 +266,29 @@ function checkDeps(workdir, providerName, cfg) {
265
266
  return { issues, provider: providerName };
266
267
  }
267
268
 
269
+ // 同步获取 HTTP 状态码:优先 curl(Linux/macOS),Windows 用 powershell,都没有回退 node 子进程。
270
+ function httpStatusSync(u, healthPath, timeoutMs) {
271
+ const url = u.href.replace(/\/+$/, '') + healthPath;
272
+ // 1) curl
273
+ try {
274
+ const out = execSync(`curl -s -o /dev/null -w "%{http_code}" --max-time ${Math.ceil(timeoutMs / 1000)} "${url}"`,
275
+ { encoding: 'utf8', stdio: ['pipe', 'pipe', 'pipe'], windowsHide: true }).trim();
276
+ if (/^\d+$/.test(out)) return parseInt(out, 10);
277
+ } catch (e) { /* 无 curl 或请求失败,继续 */ }
278
+ // 2) Windows powershell
279
+ if (process.platform === 'win32') {
280
+ try {
281
+ const ps = `$r=try{(Invoke-WebRequest -Uri '${url}' -TimeoutSec ${Math.ceil(timeoutMs / 1000)} -UseBasicParsing).StatusCode}catch{if($_.Exception.Response){[int]$_.Exception.Response.StatusCode}else{0}}; $r`;
282
+ const out = execSync(`powershell -NoProfile -Command "${ps}"`,
283
+ { encoding: 'utf8', stdio: ['pipe', 'pipe', 'pipe'], windowsHide: true }).trim();
284
+ const n = parseInt(out, 10);
285
+ return isNaN(n) || n === 0 ? null : n;
286
+ } catch (e) { return null; }
287
+ }
288
+ // 3) 无工具可用(Linux 无 curl 极少见): 返回 null 视为未知,不误报也不放行真故障
289
+ return -1;
290
+ }
291
+
268
292
  /**
269
293
  * 自动修复(仅 autoFixable=true 的)
270
294
  */