iranti-control-plane 0.4.3 → 0.5.0
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/bin/iranti-cp.js +39 -15
- package/dist/server/bundle.cjs +24948 -3186
- package/package.json +1 -1
- package/public/control-plane/assets/index-BTD8_zu4.css +1 -0
- package/public/control-plane/assets/index-CcG4ZB0K.js +77 -0
- package/public/control-plane/index.html +2 -2
- package/public/control-plane/assets/index-Dmr1zIws.css +0 -1
- package/public/control-plane/assets/index-Frqi9R2P.js +0 -77
package/bin/iranti-cp.js
CHANGED
|
@@ -119,26 +119,50 @@ async function fetchJson(url, timeoutMs = 1500) {
|
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
+
async function probeControlPlane(port) {
|
|
123
|
+
try {
|
|
124
|
+
const ping = await fetchJson(`http://127.0.0.1:${port}/api/control-plane/ping`, 1000);
|
|
125
|
+
const packageName = typeof ping.package === 'string' ? ping.package : null;
|
|
126
|
+
if (packageName && packageName !== PACKAGE_NAME) {
|
|
127
|
+
return null;
|
|
128
|
+
}
|
|
129
|
+
return {
|
|
130
|
+
port,
|
|
131
|
+
url: `http://localhost:${port}/control-plane`,
|
|
132
|
+
version: typeof ping.version === 'string' ? ping.version : null,
|
|
133
|
+
instances: null,
|
|
134
|
+
};
|
|
135
|
+
} catch {
|
|
136
|
+
// Fall back to the heavier health probe so older control-plane builds
|
|
137
|
+
// without /ping still remain discoverable.
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
try {
|
|
141
|
+
const health = await fetchJson(`http://127.0.0.1:${port}/api/control-plane/health`, 5000);
|
|
142
|
+
return {
|
|
143
|
+
port,
|
|
144
|
+
url: `http://localhost:${port}/control-plane`,
|
|
145
|
+
version: typeof health.version === 'string' ? health.version : null,
|
|
146
|
+
instances: null,
|
|
147
|
+
};
|
|
148
|
+
} catch {
|
|
149
|
+
return null;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
122
153
|
async function findRunningControlPlanes(explicitPort) {
|
|
123
154
|
const checks = preferredPorts(explicitPort).map(async (port) => {
|
|
155
|
+
const running = await probeControlPlane(port);
|
|
156
|
+
if (!running) return null;
|
|
157
|
+
|
|
124
158
|
try {
|
|
125
|
-
const
|
|
126
|
-
|
|
127
|
-
try {
|
|
128
|
-
const body = await fetchJson(`http://127.0.0.1:${port}/api/control-plane/instances`, 1500);
|
|
129
|
-
instances = Array.isArray(body) ? body.length : null;
|
|
130
|
-
} catch {
|
|
131
|
-
instances = null;
|
|
132
|
-
}
|
|
133
|
-
return {
|
|
134
|
-
port,
|
|
135
|
-
url: `http://localhost:${port}/control-plane`,
|
|
136
|
-
version: typeof health.version === 'string' ? health.version : null,
|
|
137
|
-
instances,
|
|
138
|
-
};
|
|
159
|
+
const body = await fetchJson(`http://127.0.0.1:${port}/api/control-plane/instances`, 2000);
|
|
160
|
+
running.instances = Array.isArray(body) ? body.length : null;
|
|
139
161
|
} catch {
|
|
140
|
-
|
|
162
|
+
running.instances = null;
|
|
141
163
|
}
|
|
164
|
+
|
|
165
|
+
return running;
|
|
142
166
|
});
|
|
143
167
|
|
|
144
168
|
const resolved = await Promise.all(checks);
|