@danhachuel/thunderbolt 0.2.95 → 0.2.96
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/package.json +1 -1
- package/scripts/cli.mjs +13 -3
package/package.json
CHANGED
package/scripts/cli.mjs
CHANGED
|
@@ -153,7 +153,15 @@ if (args[0] === "pipeline-worker" || args.includes("--pipeline-worker")) {
|
|
|
153
153
|
|
|
154
154
|
const port = process.env.THUNDERBOLT_PORT || process.env.HERMES_PORT || "3030";
|
|
155
155
|
const publicPort = Number.parseInt(String(port), 10);
|
|
156
|
-
const backendPort =
|
|
156
|
+
const backendPort = await new Promise((resolve, reject) => {
|
|
157
|
+
const reservation = net.createServer();
|
|
158
|
+
reservation.once("error", reject);
|
|
159
|
+
reservation.listen(0, "127.0.0.1", () => {
|
|
160
|
+
const address = reservation.address();
|
|
161
|
+
const selectedPort = address && typeof address === "object" ? address.port : 0;
|
|
162
|
+
reservation.close((error) => error ? reject(error) : resolve(selectedPort));
|
|
163
|
+
});
|
|
164
|
+
});
|
|
157
165
|
const supportedLanguages = new Set(["en", "zh", "de", "vi", "tr", "pt", "ru", "es", "id", "it"]);
|
|
158
166
|
|
|
159
167
|
const proxy = http.createServer((request, response) => {
|
|
@@ -196,7 +204,9 @@ proxy.on("upgrade", (request, clientSocket, head) => {
|
|
|
196
204
|
upstreamSocket.on("error", () => clientSocket.destroy());
|
|
197
205
|
});
|
|
198
206
|
|
|
199
|
-
proxy.listen(publicPort, "127.0.0.1")
|
|
207
|
+
proxy.listen(publicPort, "127.0.0.1", () => {
|
|
208
|
+
console.log(`Thunderbolt: interface disponível em http://localhost:${publicPort}/`);
|
|
209
|
+
});
|
|
200
210
|
const worker = spawn(python, ["-m", "hermes_ui.automation_worker"], {
|
|
201
211
|
cwd: root,
|
|
202
212
|
stdio: "inherit",
|
|
@@ -211,7 +221,7 @@ const pipelineWorker = spawn(python, ["-m", "hermes_ui.pipeline_worker"], {
|
|
|
211
221
|
});
|
|
212
222
|
const child = spawn(python, ["-m", "streamlit", "run", main, "--server.port", String(backendPort), "--server.address", "127.0.0.1"], {
|
|
213
223
|
cwd: root,
|
|
214
|
-
stdio: "
|
|
224
|
+
stdio: "ignore",
|
|
215
225
|
env: runtimeEnv,
|
|
216
226
|
windowsHide: false,
|
|
217
227
|
});
|