From 338456b79de2e039e6faec649c490464da64f00a Mon Sep 17 00:00:00 2001 From: robertvoy Date: Wed, 16 Jul 2025 13:01:05 +1000 Subject: [PATCH] auto detect runpod host --- web/main.js | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/web/main.js b/web/main.js index 7d00c38..7a5be5d 100644 --- a/web/main.js +++ b/web/main.js @@ -771,6 +771,12 @@ class DistributedExtension { async detectMasterIP() { try { + // Detect if we're running on Runpod + const isRunpod = window.location.hostname.endsWith('.proxy.runpod.net'); + if (isRunpod) { + this.log("Detected Runpod environment", "info"); + } + const data = await this.api.getNetworkInfo(); this.log("Network info: " + JSON.stringify(data), "debug"); @@ -826,7 +832,8 @@ class DistributedExtension { host: "localhost", port: 8189 + portOffset, cuda_device: i, - enabled: true + enabled: true, + extra_args: isRunpod ? "--listen" : "" }; newWorkers.push(worker); workerNum++; @@ -875,6 +882,30 @@ class DistributedExtension { return; } + // For Runpod, use the proxy hostname as master host + if (isRunpod) { + const runpodHost = window.location.hostname; + this.log(`Setting Runpod master host: ${runpodHost}`, "info"); + + // Save the Runpod host + await this.api.updateMaster({ host: runpodHost }); + + // Update local config + if (!this.config.master) this.config.master = {}; + this.config.master.host = runpodHost; + + // Show notification + if (app.extensionManager?.toast) { + app.extensionManager.toast.add({ + severity: "info", + summary: "Runpod Auto-Configuration", + detail: `Master host set to ${runpodHost} with --listen flag for workers`, + life: 5000 + }); + } + return; // Skip regular IP detection for Runpod + } + // Use the recommended IP from the backend if (data.recommended_ip && data.recommended_ip !== '127.0.0.1') { this.log(`Auto-detected master IP: ${data.recommended_ip}`, "info");