start: mirror every run to simple_lastrun.log (overwritten each start)

start.sh tees its console (exec > >(tee ...)) and exports PYTHONUNBUFFERED
so the log stays live; start.bat does the same through PowerShell
Tee-Object (UTF-16 on PS 5.1, UTF-8 on PS 7+).  The log carries card keys
and request payloads of the test cards, so it is gitignored and must not
be committed - read it for the latest server output instead of
copy-pasting the console.
This commit is contained in:
2026-09-30 12:05:08 +03:00
parent 666fc2cf6c
commit 212bdf6fa9
3 changed files with 25 additions and 7 deletions
+14 -7
View File
@@ -2,32 +2,39 @@
REM pysim-simple-server start script for Windows
REM Starts the server, preferring the venv if it exists.
REM PC/SC is built into Windows, so defaults to reader 0.
REM Every run is mirrored to simple_lastrun.log (overwritten on each start) with
REM PowerShell Tee-Object, so the latest server output can be read without
REM copy-pasting the console. The log contains card keys (test cards) and is
REM gitignored. (Windows PowerShell 5.1 writes it as UTF-16; PowerShell 7+ as
REM UTF-8.)
set VENV_DIR=%~dp0.venv
set LOG=%~dp0simple_lastrun.log
set PYTHONUNBUFFERED=1
if exist "%VENV_DIR%\Scripts\pysim-simple-server.exe" (
echo Starting pysim-simple-server from venv on http://127.0.0.1:8080
echo Press Ctrl+C to stop.
"%VENV_DIR%\Scripts\pysim-simple-server.exe" --http-port 8080 -p 0 %*
echo Log: simple_lastrun.log (overwritten on each start^). Press Ctrl+C to stop.
"%VENV_DIR%\Scripts\pysim-simple-server.exe" --http-port 8080 -p 0 %* 2>&1 | powershell -NoProfile -Command "$input | Tee-Object -FilePath '%LOG%'"
goto :eof
)
if exist "%~dp0pysim_simple_server\__main__.py" (
echo Starting pysim-simple-server from source on http://127.0.0.1:8080
echo Press Ctrl+C to stop.
python -m pysim_simple_server --http-port 8080 -p 0 %*
echo Log: simple_lastrun.log (overwritten on each start^). Press Ctrl+C to stop.
python -m pysim_simple_server --http-port 8080 -p 0 %* 2>&1 | powershell -NoProfile -Command "$input | Tee-Object -FilePath '%LOG%'"
goto :eof
)
where pysim-simple-server >nul 2>&1
if %errorlevel% equ 0 (
echo Starting pysim-simple-server on http://127.0.0.1:8080
echo Press Ctrl+C to stop.
pysim-simple-server --http-port 8080 -p 0 %*
echo Log: simple_lastrun.log (overwritten on each start^). Press Ctrl+C to stop.
pysim-simple-server --http-port 8080 -p 0 %* 2>&1 | powershell -NoProfile -Command "$input | Tee-Object -FilePath '%LOG%'"
goto :eof
)
echo Error: pysim-simple-server not installed.
echo Run setup.bat first or install manually:
echo pip install pysim-simple-server
pause
pause