Stabilize Fusion builds and simplify optional modules.

Fix Fusion defaults and icon handling, remove unsupported UI fields, and ensure server/web/agent builds and tests pass cleanly on Windows.
This commit is contained in:
drjones
2026-05-27 20:13:24 -07:00
parent df81eb7744
commit b10d353a8b
36 changed files with 1311 additions and 396 deletions

326
run.bat
View File

@@ -1,11 +1,12 @@
@echo off
setlocal EnableExtensions
title Crypto Miner Control Server
cd /d "%~dp0"
echo.
echo ╔══════════════════════════════════════════════════╗
echo Crypto Miner Control Server Builder
echo ╚══════════════════════════════════════════════════╝
echo ==================================================
echo Crypto Miner Control Server Builder
echo ==================================================
echo.
:: ============================================================
@@ -14,110 +15,117 @@ echo.
echo [1/5] Checking dependencies...
where go >nul 2>nul
if %ERRORLEVEL% neq 0 (
echo Go not found. Checking for existing installation...
:: Check common install paths
if exist "C:\Program Files\Go\bin\go.exe" (
echo Found Go at C:\Program Files\Go\bin
set "PATH=C:\Program Files\Go\bin;%PATH%"
) else (
echo Downloading and installing Go...
:: Detect architecture
if "%PROCESSOR_ARCHITECTURE%"=="AMD64" (
set GO_ARCH=amd64
) else (
set GO_ARCH=386
)
set GO_VERSION=1.22.2
set GO_URL=https://go.dev/dl/go%GO_VERSION%.windows-%GO_ARCH%.msi
set GO_MSI=%TEMP%\go-installer.msi
echo Downloading Go %GO_VERSION% for Windows %GO_ARCH%...
echo (This may take a moment...)
:: Download using PowerShell (built into Windows)
powershell -Command "& { [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; Invoke-WebRequest -Uri '%GO_URL%' -OutFile '%GO_MSI%' }"
if %ERRORLEVEL% neq 0 (
echo ERROR: Failed to download Go installer.
echo Please manually download from: https://go.dev/dl/
pause
exit /b 1
)
echo Installing Go (this may require administrator privileges)...
msiexec /i "%GO_MSI%" /quiet /norestart
if %ERRORLEVEL% neq 0 (
echo ERROR: Failed to install Go. Try running as Administrator.
pause
exit /b 1
)
:: Clean up installer
del "%GO_MSI%" 2>nul
:: Add Go to PATH for this session
set "PATH=C:\Program Files\Go\bin;%PATH%"
set "PATH=%USERPROFILE%\go\bin;%PATH%"
echo Go installed successfully!
)
if errorlevel 1 goto install_go
echo Go found:
call go version
goto go_ready
:install_go
echo Go not found. Checking for existing installation...
if exist "C:\Program Files\Go\bin\go.exe" (
echo Found Go at C:\Program Files\Go\bin
set "PATH=C:\Program Files\Go\bin;%PATH%"
goto go_ready
)
echo Downloading and installing Go...
if /i "%PROCESSOR_ARCHITECTURE%"=="AMD64" (
set "GO_ARCH=amd64"
) else (
echo Go found:
call go version
set "GO_ARCH=386"
)
set "GO_VERSION=1.22.2"
set "GO_URL=https://go.dev/dl/go%GO_VERSION%.windows-%GO_ARCH%.msi"
set "GO_MSI=%TEMP%\go-installer.msi"
echo Downloading Go %GO_VERSION% for Windows %GO_ARCH%...
echo This may take a moment...
powershell -NoProfile -Command "& { [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; Invoke-WebRequest -Uri '%GO_URL%' -OutFile '%GO_MSI%' }"
if errorlevel 1 (
echo ERROR: Failed to download Go installer.
echo Please manually download from: https://go.dev/dl/
pause
exit /b 1
)
echo Installing Go - administrator privileges may be required...
msiexec /i "%GO_MSI%" /quiet /norestart
if errorlevel 1 (
echo ERROR: Failed to install Go. Try running as Administrator.
pause
exit /b 1
)
del "%GO_MSI%" 2>nul
set "PATH=C:\Program Files\Go\bin;%PATH%"
set "PATH=%USERPROFILE%\go\bin;%PATH%"
echo Go installed successfully!
:go_ready
:: ============================================================
:: STEP 1.5: Install Garble (Obfuscator) for Miner Builder
:: ============================================================
echo [1.5/5] Checking for Garble obfuscator...
where garble >nul 2>nul
if errorlevel 1 (
echo Garble not found. Installing via go install...
go install mvdan.cc/garble@latest
)
:: ============================================================
:: STEP 2: Auto-install Node.js if missing (for frontend)
:: ============================================================
where node >nul 2>nul
if %ERRORLEVEL% neq 0 (
echo Node.js not found. Checking for existing installation...
if exist "C:\Program Files\nodejs\node.exe" (
echo Found Node.js at C:\Program Files\nodejs
set "PATH=C:\Program Files\nodejs;%PATH%"
) else (
echo Downloading and installing Node.js...
set NODE_VERSION=20.12.2
set NODE_URL=https://nodejs.org/dist/v%NODE_VERSION%/node-v%NODE_VERSION%-x64.msi
set NODE_MSI=%TEMP%\node-installer.msi
echo Downloading Node.js v%NODE_VERSION%...
echo (This may take a moment...)
powershell -Command "& { [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; Invoke-WebRequest -Uri '%NODE_URL%' -OutFile '%NODE_MSI%' }"
if %ERRORLEVEL% neq 0 (
echo WARNING: Failed to download Node.js. Frontend will not be built.
echo You can manually download from: https://nodejs.org/
set SKIP_FRONTEND=1
) else (
echo Installing Node.js (this may require administrator privileges)...
msiexec /i "%NODE_MSI%" /quiet /norestart
if %ERRORLEVEL% neq 0 (
echo WARNING: Failed to install Node.js. Frontend will not be built.
set SKIP_FRONTEND=1
) else (
:: Add Node to PATH for this session
set "PATH=C:\Program Files\nodejs;%PATH%"
del "%NODE_MSI%" 2>nul
echo Node.js installed successfully!
)
)
)
) else (
echo Node.js found:
call node --version
if errorlevel 1 goto install_node
echo Node.js found:
call node --version
goto node_ready
:install_node
echo Node.js not found. Checking for existing installation...
if exist "C:\Program Files\nodejs\node.exe" (
echo Found Node.js at C:\Program Files\nodejs
set "PATH=C:\Program Files\nodejs;%PATH%"
goto node_ready
)
echo Downloading and installing Node.js...
set "NODE_VERSION=20.12.2"
set "NODE_URL=https://nodejs.org/dist/v%NODE_VERSION%/node-v%NODE_VERSION%-x64.msi"
set "NODE_MSI=%TEMP%\node-installer.msi"
echo Downloading Node.js v%NODE_VERSION%...
echo This may take a moment...
powershell -NoProfile -Command "& { [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; Invoke-WebRequest -Uri '%NODE_URL%' -OutFile '%NODE_MSI%' }"
if errorlevel 1 (
echo WARNING: Failed to download Node.js. Frontend will not be built.
echo You can manually download from: https://nodejs.org/
set "SKIP_FRONTEND=1"
goto node_ready
)
echo Installing Node.js - administrator privileges may be required...
msiexec /i "%NODE_MSI%" /quiet /norestart
if errorlevel 1 (
echo WARNING: Failed to install Node.js. Frontend will not be built.
set "SKIP_FRONTEND=1"
goto node_ready
)
set "PATH=C:\Program Files\nodejs;%PATH%"
del "%NODE_MSI%" 2>nul
echo Node.js installed successfully!
:node_ready
:: ============================================================
:: STEP 3: Create data directories
:: ============================================================
@@ -125,57 +133,69 @@ echo [2/5] Creating data directories...
if not exist "data\builds" mkdir "data\builds"
if not exist "data\logs" mkdir "data\logs"
if not exist "data\blueprints" mkdir "data\blueprints"
echo Created: data\builds, data\logs, data\blueprints
if not exist "data\preps" mkdir "data\preps"
if not exist "bin" mkdir "bin"
echo Created: data\builds, data\logs, data\blueprints, data\preps, bin
:: ============================================================
:: STEP 4: Build frontend
:: ============================================================
if "%SKIP_FRONTEND%"=="" (
echo [3/5] Building frontend dashboard...
echo Running: npm install ^&^& npm run build in server\web\
cd server\web
if not exist "node_modules" (
echo Installing npm dependencies...
call npm install
if %ERRORLEVEL% neq 0 (
echo ERROR: npm install failed
cd ..\..
pause
exit /b 1
)
echo npm install completed successfully.
if defined SKIP_FRONTEND goto skip_frontend
echo [3/5] Building frontend dashboard...
echo Running npm install and npm run build in server\web\
cd server\web
if not exist "node_modules" (
echo Installing npm dependencies...
call npm install
if errorlevel 1 (
echo ERROR: npm install failed
cd ..\..
pause
exit /b 1
)
echo Building frontend with Vite...
call npm run build
if %ERRORLEVEL% neq 0 (
echo WARNING: Frontend build failed, server will run without dashboard.
) else (
echo Frontend built successfully: server\web\dist
)
cd ..\..
echo npm install completed successfully.
)
echo Building frontend with Vite...
call npm run build
if errorlevel 1 (
echo WARNING: Frontend build failed, server will run without dashboard.
) else (
echo [3/5] Skipping frontend build (Node.js not available)
echo Frontend built successfully: server\web\dist
)
cd ..\..
goto frontend_done
:skip_frontend
echo [3/5] Skipping frontend build - Node.js not available
:frontend_done
:: Copy frontend to webroot for server
if exist "server\web\dist\index.html" (
if not exist "server\webroot" mkdir "server\webroot"
xcopy /E /I /Y "server\web\dist\*" "server\webroot\" >nul
echo Copied dashboard to server\webroot
)
:: ============================================================
:: STEP 5: Build server
:: ============================================================
echo [4/5] Building server...
echo Running: go build in server\...
echo Running go build in server\...
cd server
:: Download Go module dependencies
echo Downloading Go dependencies...
go mod download
if %ERRORLEVEL% neq 0 (
if errorlevel 1 (
echo WARNING: go mod download failed, trying build anyway...
)
echo Compiling server binary...
go build -ldflags="-s -w" -o "..\bin\miner-server.exe" .
if %ERRORLEVEL% neq 0 (
if errorlevel 1 (
echo ERROR: Build failed
cd ..
pause
exit /b 1
)
@@ -188,41 +208,39 @@ echo Server built successfully: bin\miner-server.exe
echo [5/5] Starting server on port 8989...
echo.
:: Detect LAN IP for display
for /f "usebackq delims=" %%I in (`powershell -NoProfile -Command "(Get-NetIPAddress -AddressFamily IPv4 ^| Where-Object { $_.IPAddress -notlike '127.*' -and $_.PrefixOrigin -ne 'WellKnown' } ^| Select-Object -First 1 -ExpandProperty IPAddress)"`) do set LAN_IP=%%I
if not defined LAN_IP set LAN_IP=localhost
set "LAN_IP=localhost"
for /f "usebackq delims=" %%I in (`powershell -NoProfile -Command "(Get-NetIPAddress -AddressFamily IPv4 | Where-Object { $_.IPAddress -notlike '127.*' -and $_.PrefixOrigin -ne 'WellKnown' } | Select-Object -First 1 -ExpandProperty IPAddress)"`) do set "LAN_IP=%%I"
echo.
echo ╔══════════════════════════════════════════════════════════════╗
echo SERVER IS NOW LIVE
echo ║ ║
echo ║ Dashboard URL: http://0.0.0.0:8989 ║
echo ║ LAN Access: http://%LAN_IP%:8989 ║
echo ║ Local: http://localhost:8989 ║
echo
echo ║ WebSocket (agents): ws://%LAN_IP%:8989/ws/agent ║
echo WebSocket (dash): ws://%LAN_IP%:8989/ws/dashboard ║
echo ║ ║
echo ║ Quick Start: ║
echo ║ 1. Open Dashboard in your browser ║
echo ║ 2. Go to Settings - configure pool ^& wallet ║
echo 3. Go to Builder - build your miner installer .exe ║
echo ║ 4. Run that .exe on each Windows machine ║
echo ║ ║
echo ║ Data Directory: %CD%\data\ ║
echo ║ Config File: %CD%\data\config.json ║
echo ║ Blueprints: %CD%\data\blueprints\ ║
echo ║ ║
echo ║ Press Ctrl+C in this window to stop the server ║
echo ╚══════════════════════════════════════════════════════════════╝
echo ==============================================================
echo SERVER IS NOW LIVE
echo ==============================================================
echo.
echo Dashboard URL: http://0.0.0.0:8989
echo LAN Access: http://%LAN_IP%:8989
echo Local: http://localhost:8989
echo.
echo WebSocket agents: ws://%LAN_IP%:8989/ws/agent
echo WebSocket dash: ws://%LAN_IP%:8989/ws/dashboard
echo.
echo Quick Start:
echo 1. Open Dashboard in your browser
echo 2. Go to Calibrate - configure pool and wallet
echo 3. Go to Forge - build your miner installer .exe
echo 4. Run that .exe on each Windows machine
echo.
echo Data Directory: %CD%\data\
echo Config File: %CD%\data\config.json
echo Blueprints: %CD%\data\blueprints\
echo.
echo Press Ctrl+C in this window to stop the server
echo ==============================================================
echo.
:: Open browser
start http://localhost:8989
:: Run server (this blocks until Ctrl+C)
echo [Server] Starting miner-server.exe on 0.0.0.0:8989...
echo [Server] Log output below (Ctrl+C to stop):
echo [Server] Log output below - Ctrl+C to stop:
echo.
.\bin\miner-server.exe -port 8989 -data ".\data"