Search/run.bat
partisan 59e0ee33a5
Some checks failed
Run Integration Tests / test (push) Failing after 42s
FIxed run.sh and run.bat
2025-06-01 09:54:09 +02:00

70 lines
1.4 KiB
Batchfile
Executable file

@echo off
setlocal enabledelayedexpansion
rem Initialize variables
set SKIP_CONFIG=""
set PORT=""
set DOMAIN=""
set CONFIG_FILE=""
set BUILD_OUTPUT=qgato.exe
rem Parse arguments
:parse_args
if "%~1"=="" goto end_parse
if "%~1"=="--port" (
set PORT=%~2
shift
shift
goto parse_args
)
if "%~1"=="--domain" (
set DOMAIN=%~2
shift
shift
goto parse_args
)
if "%~1"=="--config" (
set CONFIG_FILE=%~2
shift
shift
goto parse_args
)
if "%~1"=="--skip-config-check" (
set SKIP_CONFIG=--skip-config-check
shift
goto parse_args
)
echo Unknown argument: %~1
exit /b 1
:end_parse
rem Use the current directory where the script is executed
pushd %~dp0
rem Always delete and rebuild the binary
echo Cleaning previous build...
if exist "%BUILD_OUTPUT%" del "%BUILD_OUTPUT%"
echo Building application...
go build -ldflags="-s -w" -o "%BUILD_OUTPUT%" .
if errorlevel 1 (
echo Build failed!
exit /b 1
)
echo Build successful! Output: %CD%\%BUILD_OUTPUT%
rem Construct the command
set CMD=%BUILD_OUTPUT% !SKIP_CONFIG!
if not "%PORT%"=="" set CMD=!CMD! --port %PORT%
if not "%DOMAIN%"=="" set CMD=!CMD! --domain %DOMAIN%
if not "%CONFIG_FILE%"=="" set CMD=!CMD! --config %CONFIG_FILE%
rem Informative output
echo Starting application with command: !CMD!
rem Run the built executable
call !CMD!
rem Return to the original directory
popd