@devness/useai 0.4.19 → 0.4.20
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.
- package/dist/index.js +29 -11
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -112,7 +112,7 @@ var VERSION;
|
|
|
112
112
|
var init_version = __esm({
|
|
113
113
|
"../shared/dist/constants/version.js"() {
|
|
114
114
|
"use strict";
|
|
115
|
-
VERSION = "0.4.
|
|
115
|
+
VERSION = "0.4.20";
|
|
116
116
|
}
|
|
117
117
|
});
|
|
118
118
|
|
|
@@ -561,6 +561,17 @@ async function checkDaemonHealth() {
|
|
|
561
561
|
return false;
|
|
562
562
|
}
|
|
563
563
|
}
|
|
564
|
+
async function fetchDaemonHealth(port) {
|
|
565
|
+
try {
|
|
566
|
+
const url = port ? `http://127.0.0.1:${port}/health` : DAEMON_HEALTH_URL;
|
|
567
|
+
const res = await fetch(url, { signal: AbortSignal.timeout(3e3) });
|
|
568
|
+
if (res.ok)
|
|
569
|
+
return await res.json();
|
|
570
|
+
return null;
|
|
571
|
+
} catch {
|
|
572
|
+
return null;
|
|
573
|
+
}
|
|
574
|
+
}
|
|
564
575
|
async function killDaemon() {
|
|
565
576
|
const pid = readPidFile();
|
|
566
577
|
if (!pid)
|
|
@@ -595,15 +606,21 @@ async function killDaemon() {
|
|
|
595
606
|
}
|
|
596
607
|
}
|
|
597
608
|
async function ensureDaemon() {
|
|
598
|
-
|
|
609
|
+
const health = await fetchDaemonHealth();
|
|
610
|
+
if (health && health.version === VERSION)
|
|
599
611
|
return true;
|
|
600
|
-
|
|
601
|
-
if (pid && isProcessRunning(pid.pid)) {
|
|
612
|
+
if (health) {
|
|
602
613
|
await killDaemon();
|
|
603
|
-
}
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
614
|
+
}
|
|
615
|
+
if (!health) {
|
|
616
|
+
const pid = readPidFile();
|
|
617
|
+
if (pid && isProcessRunning(pid.pid)) {
|
|
618
|
+
await killDaemon();
|
|
619
|
+
} else if (pid) {
|
|
620
|
+
try {
|
|
621
|
+
unlinkSync(DAEMON_PID_FILE);
|
|
622
|
+
} catch {
|
|
623
|
+
}
|
|
607
624
|
}
|
|
608
625
|
}
|
|
609
626
|
let npxPath;
|
|
@@ -629,6 +646,7 @@ var init_ensure = __esm({
|
|
|
629
646
|
"../shared/dist/daemon/ensure.js"() {
|
|
630
647
|
"use strict";
|
|
631
648
|
init_paths();
|
|
649
|
+
init_version();
|
|
632
650
|
init_resolve_npx();
|
|
633
651
|
}
|
|
634
652
|
});
|
|
@@ -660,7 +678,7 @@ function buildPlist(npxPath, nodePath) {
|
|
|
660
678
|
<array>
|
|
661
679
|
<string>${npxPath}</string>
|
|
662
680
|
<string>-y</string>
|
|
663
|
-
<string>@devness/useai</string>
|
|
681
|
+
<string>@devness/useai@latest</string>
|
|
664
682
|
<string>daemon</string>
|
|
665
683
|
<string>--port</string>
|
|
666
684
|
<string>${DAEMON_PORT}</string>
|
|
@@ -719,7 +737,7 @@ After=network.target
|
|
|
719
737
|
|
|
720
738
|
[Service]
|
|
721
739
|
Type=simple
|
|
722
|
-
ExecStart=${npxPath} -y @devness/useai daemon --port ${DAEMON_PORT}
|
|
740
|
+
ExecStart=${npxPath} -y @devness/useai@latest daemon --port ${DAEMON_PORT}
|
|
723
741
|
Restart=on-failure
|
|
724
742
|
RestartSec=10
|
|
725
743
|
Environment=PATH=${nodePath}
|
|
@@ -756,7 +774,7 @@ function isLinuxInstalled() {
|
|
|
756
774
|
}
|
|
757
775
|
function buildVbsScript(npxPath) {
|
|
758
776
|
return `Set WshShell = CreateObject("WScript.Shell")
|
|
759
|
-
WshShell.Run """${npxPath}"" -y @devness/useai daemon --port ${DAEMON_PORT}", 0, False
|
|
777
|
+
WshShell.Run """${npxPath}"" -y @devness/useai@latest daemon --port ${DAEMON_PORT}", 0, False
|
|
760
778
|
`;
|
|
761
779
|
}
|
|
762
780
|
function installWindows() {
|