Ver código fonte

fix port start

spacexerq 1 dia atrás
pai
commit
5cc36f0364

+ 2 - 2
.env.example

@@ -2,13 +2,13 @@
 # Change these if the default ports conflict with other local services.
 ORCHESTRATOR_PORT=1717
 SEQ_INTERP_PORT=7475
-SPECTROMETER_PORT=8000
+SPECTROMETER_PORT=1818
 RECONSTRUCTOR_PORT=8081
 SPECTROSCOPY_PORT=8002
 
 # -- Orchestrator mode ----------------------------------------------------------
 # plug  - stub tasks (instant responses, no hardware required)
-# real  - live tasks (calls spectrometer at 8000 and reconstructor at 8081)
+# real  - live tasks (calls spectrometer at 1818 and reconstructor at 8081)
 ORCHESTRATOR_MODE=plug
 
 # -- Image versions -------------------------------------------------------------

+ 3 - 0
apps/gui/app.py

@@ -64,6 +64,7 @@ def main() -> None:
     orchestrator_url = "http://localhost:1717"
     seq_interp_url   = "http://localhost:7475"
     spectroscopy_url = "http://localhost:8002"
+    spectrometer_url = "http://localhost:1818"
     hw_mode          = "plug"
     try:
         import json as _json
@@ -72,6 +73,7 @@ def main() -> None:
         orchestrator_url = _cfg.get("orchestrator_url", orchestrator_url)
         seq_interp_url   = _cfg.get("seq_interp_url",   seq_interp_url)
         spectroscopy_url = _cfg.get("spectroscopy_url", spectroscopy_url)
+        spectrometer_url = _cfg.get("spectrometer_url", spectrometer_url)
         hw_mode          = _cfg.get("mode", hw_mode)
     except Exception:
         pass
@@ -83,6 +85,7 @@ def main() -> None:
         orchestrator_url=orchestrator_url,
         seq_interp_url=seq_interp_url,
         spectroscopy_url=spectroscopy_url,
+        spectrometer_url=spectrometer_url,
         hw_mode=hw_mode,
     )
     # Start in a maximized windowed state so the app fills the usable screen

+ 2 - 1
apps/gui/cfg/server_config.json

@@ -7,5 +7,6 @@
   "server_port": 7475,
   "orchestrator_url": "http://localhost:1717",
   "seq_interp_url": "http://localhost:7475",
-  "spectroscopy_url": "http://localhost:8002"
+  "spectroscopy_url": "http://localhost:8002",
+  "spectrometer_url": "http://localhost:1818"
 }

+ 1 - 1
apps/gui/src/app_window.py

@@ -189,7 +189,7 @@ class LFMRIWindow(QMainWindow):
         seq_interp_url:    str = "http://localhost:7475",
         spectroscopy_url:  str = "http://localhost:8002",
         reconstructor_url: str = "http://localhost:8081",
-        spectrometer_url:  str = "http://localhost:8000",
+        spectrometer_url:  str = "http://localhost:1818",
         hw_mode:           str = "plug",
     ) -> None:
         super().__init__()

+ 5 - 5
apps/gui/src/tabs/scanner_tab.py

@@ -109,12 +109,12 @@ class _SpectrometerRestartWorker(QThread):
                 capture_output=True,
             )
 
-            # 2. Kill Django runserver on port 8000 (find PID via netstat)
+            # 2. Kill Django runserver on port 1818 (find PID via netstat)
             self.log.emit("Stopping Django runserver…")
             try:
                 r = subprocess.run(
                     ["powershell", "-Command",
-                     "Get-NetTCPConnection -LocalPort 8000 -State Listen "
+                     "Get-NetTCPConnection -LocalPort 1818 -State Listen "
                      "-ErrorAction SilentlyContinue | "
                      "Select-Object -ExpandProperty OwningProcess"],
                     capture_output=True, text=True, timeout=10,
@@ -151,9 +151,9 @@ class _SpectrometerRestartWorker(QThread):
                 self.log.emit("  pico-tcp.exe not found — skipped")
 
             # 5. Start Django runserver
-            self.log.emit("Starting Django runserver (0.0.0.0:8000)…")
+            self.log.emit("Starting Django runserver (0.0.0.0:1818)…")
             subprocess.Popen(
-                [venv, "manage.py", "runserver", "0.0.0.0:8000", "--noreload"],
+                [venv, "manage.py", "runserver", "0.0.0.0:1818", "--noreload"],
                 cwd=spec,
                 creationflags=subprocess.CREATE_NEW_CONSOLE,
             )
@@ -417,7 +417,7 @@ class ScannerTab(QWidget):
         seq_interp_url: str = "http://localhost:7475",
         reconstructor_url: str = "http://localhost:8081",
         spectroscopy_url: str = "http://localhost:8002",
-        spectrometer_url: str = "http://localhost:8000",
+        spectrometer_url: str = "http://localhost:1818",
         parent: QWidget | None = None,
     ) -> None:
         super().__init__(parent)

+ 1 - 1
docker-compose.yml

@@ -13,7 +13,7 @@ services:
       MODE: ${ORCHESTRATOR_MODE:-plug}
       # Spectrometer runs natively on the Windows host — not in Docker.
       # On Windows with Docker Desktop use host.docker.internal; override via .env.
-      SPECTROMETER_URL: ${SPECTROMETER_URL:-http://host.docker.internal:8000}
+      SPECTROMETER_URL: ${SPECTROMETER_URL:-http://host.docker.internal:${SPECTROMETER_PORT:-1818}}
       RECONSTRUCTOR_URL: http://reconstructor:8000
       SEQ_INTERP_URL: http://seq-interp:7475
       SPECTROMETER_USER: ${SPECTROMETER_USER:-admin}

+ 1 - 1
services/orchestrator/orchestrator/clients/spec_cl.py

@@ -5,7 +5,7 @@ from requests.auth import HTTPBasicAuth
 from typing import Any, Dict, Optional, Union
 
 class SpectrometerClient:
-    def __init__(self, base_url: str = "http://localhost:8000",
+    def __init__(self, base_url: str = "http://localhost:1818",
                  username: Optional[str] = None, password: Optional[str] = None,
                  timeout_s: float = 30.0):
         self.base = base_url.rstrip("/")

+ 1 - 1
services/orchestrator/orchestrator/healthcheck.py

@@ -8,7 +8,7 @@ from requests.auth import HTTPBasicAuth
 SERVICES = [
     {
         "name": "Spectrometer",
-        "url": "http://localhost:8000/api/",
+        "url": "http://localhost:1818/api/",
         "auth": None,
     },
     {

+ 2 - 2
services/orchestrator/orchestrator/main.py

@@ -136,7 +136,7 @@ def set_mode_endpoint(body: ModeRequest):
 @app.get("/spectrometer/health")
 def spectrometer_health():
     """Check connectivity to the spectrometer service."""
-    spec_url  = os.getenv("SPECTROMETER_URL",      "http://localhost:8000")
+    spec_url  = os.getenv("SPECTROMETER_URL",      "http://localhost:1818")
     spec_user = os.getenv("SPECTROMETER_USER",     "admin")
     spec_pass = os.getenv("SPECTROMETER_PASSWORD", "admin")
     try:
@@ -412,7 +412,7 @@ def decode_measurement_endpoint(
     """
     from .clients.spec_cl import SpectrometerClient
 
-    spectrometer_url = os.getenv("SPECTROMETER_URL", "http://localhost:8000")
+    spectrometer_url = os.getenv("SPECTROMETER_URL", "http://localhost:1818")
     spec_user = os.getenv("SPECTROMETER_USER", "admin")
     spec_pass = os.getenv("SPECTROMETER_PASSWORD", "admin")
 

+ 1 - 1
services/orchestrator/orchestrator/tasks_real.py

@@ -10,7 +10,7 @@ def _iso_now() -> str:
 
 
 # -- конфиг из env ---------------------------------------------------------
-_SPECTROMETER_URL  = os.getenv("SPECTROMETER_URL",      "http://localhost:8000")
+_SPECTROMETER_URL  = os.getenv("SPECTROMETER_URL",      "http://localhost:1818")
 _RECONSTRUCTOR_URL = os.getenv("RECONSTRUCTOR_URL",     "http://localhost:8081")
 _SPEC_USER         = os.getenv("SPECTROMETER_USER",     "admin")
 _SPEC_PASS         = os.getenv("SPECTROMETER_PASSWORD", "admin")

+ 4 - 4
services/spectrometer/AddDevices.bat

@@ -3,19 +3,19 @@ REM Register hardware devices in the spectrometer database (run once after first
 
 curl -s -X POST -H "Content-Type: application/json" ^
   -d "{\"device_type\": \"ADC\", \"brend\": \"Picoscope\", \"serial_model\": \"PS4000A\", \"proto\": \"adc_default\", \"proto_interface\": \"TCP\"}" ^
-  http://localhost:8000/api/devices/
+  http://localhost:1818/api/devices/
 
 curl -s -X POST -H "Content-Type: application/json" ^
   -d "{\"device_type\": \"SDR\", \"brend\": \"HackRF\", \"serial_model\": \"HackRF\", \"proto\": \"sdr_default\", \"proto_interface\": \"USB\"}" ^
-  http://localhost:8000/api/devices/
+  http://localhost:1818/api/devices/
 
 curl -s -X POST -H "Content-Type: application/json" ^
   -d "{\"device_type\": \"SYNC\", \"brend\": \"Arduino\", \"serial_model\": \"DuePP\", \"proto\": \"sync_default\", \"proto_interface\": \"USB\"}" ^
-  http://localhost:8000/api/devices/
+  http://localhost:1818/api/devices/
 
 curl -s -X POST -H "Content-Type: application/json" ^
   -d "{\"device_type\": \"GRA\", \"brend\": \"ITMO\", \"serial_model\": \"GRU\", \"proto\": \"gra_default\", \"proto_interface\": \"UDP\"}" ^
-  http://localhost:8000/api/devices/
+  http://localhost:1818/api/devices/
 
 echo.
 echo Devices registered.

+ 1 - 1
services/spectrometer/autorun_default.bat

@@ -3,4 +3,4 @@ taskkill /f /fi "IMAGENAME eq pico-tcp.exe"
 python -m pip install pip --upgrade
 python -m pip install -r requirements.txt
 START bin\pico-tcp.exe
-python manage.py runserver
+python manage.py runserver 0.0.0.0:1818

+ 1 - 1
services/spectrometer/autorun_default_simple.bat

@@ -1,3 +1,3 @@
 taskkill /f /fi "IMAGENAME eq pico-tcp.exe"
 START /B bin\pico-tcp.exe
-python manage.py runserver
+python manage.py runserver 0.0.0.0:1818

+ 1 - 1
services/spectrometer/autorun_default_venv.bat

@@ -4,4 +4,4 @@ taskkill /f /fi "IMAGENAME eq pico-tcp.exe"
 python -m pip install pip --upgrade
 python -m pip install -r requirements.txt
 START bin\pico-tcp.exe
-python manage.py runserver
+python manage.py runserver 0.0.0.0:1818

+ 2 - 2
start.ps1

@@ -196,7 +196,7 @@ if (-not $GuiOnly) {
         }
 
         # Django runserver -- run via "cmd /k" so window stays open on error
-        $specPort = Get-EnvPort "SPECTROMETER_PORT" "8000"
+        $specPort = Get-EnvPort "SPECTROMETER_PORT" "1818"
         $alreadyUp = $false
         try {
             $r = Invoke-WebRequest "http://localhost:$specPort/api/" `
@@ -281,7 +281,7 @@ if (-not $GuiOnly) {
         @{ Name = "Seq-Interp";    Url = "http://localhost:$(Get-EnvPort 'SEQ_INTERP_PORT'    '7475')/health"; Required = $true      },
         @{ Name = "Reconstructor"; Url = "http://localhost:$(Get-EnvPort 'RECONSTRUCTOR_PORT' '8081')/health"; Required = $true      },
         @{ Name = "Spectroscopy";  Url = "http://localhost:$(Get-EnvPort 'SPECTROSCOPY_PORT'  '8002')/health"; Required = $true      },
-        @{ Name = "Spectrometer";  Url = "http://localhost:$(Get-EnvPort 'SPECTROMETER_PORT'  '8000')/api/";  Required = $checkSpec; AllowedCodes = @(200,301,302,401,403) }
+        @{ Name = "Spectrometer";  Url = "http://localhost:$(Get-EnvPort 'SPECTROMETER_PORT'  '1818')/api/";  Required = $checkSpec; AllowedCodes = @(200,301,302,401,403) }
     )
 
     $maxWait = 120; $interval = 3; $elapsed = 0

+ 4 - 3
update.ps1

@@ -105,9 +105,10 @@ if ($RestartSpec) {
     $venvPy = Join-Path $Root "apps\gui\.venv\Scripts\python.exe"
     if (Test-Path $venvPy) { $python = $venvPy }
 
-    Write-Host "    Starting spectrometer at $specDir ..." -ForegroundColor DarkGray
+    $specPort = Get-EnvPort "SPECTROMETER_PORT" "1818"
+    Write-Host "    Starting spectrometer at $specDir (port $specPort) ..." -ForegroundColor DarkGray
     Start-Process $python `
-        -ArgumentList "manage.py runserver 0.0.0.0:8000" `
+        -ArgumentList "manage.py runserver 0.0.0.0:$specPort" `
         -WorkingDirectory $specDir `
         -WindowStyle Normal
 
@@ -130,7 +131,7 @@ $checks = @(
     @{ Name = "Orchestrator";  Url = "http://localhost:$(Get-EnvPort 'ORCHESTRATOR_PORT'  '1717')/health"; Native = $false },
     @{ Name = "Seq-Interp";    Url = "http://localhost:$(Get-EnvPort 'SEQ_INTERP_PORT'    '7475')/health"; Native = $false },
     @{ Name = "Spectroscopy";  Url = "http://localhost:$(Get-EnvPort 'SPECTROSCOPY_PORT'   '8002')/health"; Native = $false },
-    @{ Name = "Spectrometer*"; Url = "http://localhost:$(Get-EnvPort 'SPECTROMETER_PORT'   '8000')/api/";  Native = $true  }
+    @{ Name = "Spectrometer*"; Url = "http://localhost:$(Get-EnvPort 'SPECTROMETER_PORT'   '1818')/api/";  Native = $true  }
 )
 
 function Test-Port($url) {