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:
@@ -5,3 +5,4 @@ __pycache__/
|
|||||||
dist/
|
dist/
|
||||||
build/
|
build/
|
||||||
AGENTS.md
|
AGENTS.md
|
||||||
|
simple_lastrun.log
|
||||||
|
|||||||
@@ -2,28 +2,35 @@
|
|||||||
REM pysim-simple-server start script for Windows
|
REM pysim-simple-server start script for Windows
|
||||||
REM Starts the server, preferring the venv if it exists.
|
REM Starts the server, preferring the venv if it exists.
|
||||||
REM PC/SC is built into Windows, so defaults to reader 0.
|
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 VENV_DIR=%~dp0.venv
|
||||||
|
set LOG=%~dp0simple_lastrun.log
|
||||||
|
set PYTHONUNBUFFERED=1
|
||||||
|
|
||||||
if exist "%VENV_DIR%\Scripts\pysim-simple-server.exe" (
|
if exist "%VENV_DIR%\Scripts\pysim-simple-server.exe" (
|
||||||
echo Starting pysim-simple-server from venv on http://127.0.0.1:8080
|
echo Starting pysim-simple-server from venv on http://127.0.0.1:8080
|
||||||
echo Press Ctrl+C to stop.
|
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 %*
|
"%VENV_DIR%\Scripts\pysim-simple-server.exe" --http-port 8080 -p 0 %* 2>&1 | powershell -NoProfile -Command "$input | Tee-Object -FilePath '%LOG%'"
|
||||||
goto :eof
|
goto :eof
|
||||||
)
|
)
|
||||||
|
|
||||||
if exist "%~dp0pysim_simple_server\__main__.py" (
|
if exist "%~dp0pysim_simple_server\__main__.py" (
|
||||||
echo Starting pysim-simple-server from source on http://127.0.0.1:8080
|
echo Starting pysim-simple-server from source on http://127.0.0.1:8080
|
||||||
echo Press Ctrl+C to stop.
|
echo Log: simple_lastrun.log (overwritten on each start^). Press Ctrl+C to stop.
|
||||||
python -m pysim_simple_server --http-port 8080 -p 0 %*
|
python -m pysim_simple_server --http-port 8080 -p 0 %* 2>&1 | powershell -NoProfile -Command "$input | Tee-Object -FilePath '%LOG%'"
|
||||||
goto :eof
|
goto :eof
|
||||||
)
|
)
|
||||||
|
|
||||||
where pysim-simple-server >nul 2>&1
|
where pysim-simple-server >nul 2>&1
|
||||||
if %errorlevel% equ 0 (
|
if %errorlevel% equ 0 (
|
||||||
echo Starting pysim-simple-server on http://127.0.0.1:8080
|
echo Starting pysim-simple-server on http://127.0.0.1:8080
|
||||||
echo Press Ctrl+C to stop.
|
echo Log: simple_lastrun.log (overwritten on each start^). Press Ctrl+C to stop.
|
||||||
pysim-simple-server --http-port 8080 -p 0 %*
|
pysim-simple-server --http-port 8080 -p 0 %* 2>&1 | powershell -NoProfile -Command "$input | Tee-Object -FilePath '%LOG%'"
|
||||||
goto :eof
|
goto :eof
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -4,10 +4,18 @@ set -e
|
|||||||
# pysim-simple-server start script
|
# pysim-simple-server start script
|
||||||
# Starts the server, preferring the venv if it exists.
|
# Starts the server, preferring the venv if it exists.
|
||||||
# Auto-detects PC/SC reader if available.
|
# Auto-detects PC/SC reader if available.
|
||||||
|
# Every run is mirrored to simple_lastrun.log (overwritten on each start) so the
|
||||||
|
# latest server output can be read without copy-pasting the console.
|
||||||
|
|
||||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||||
VENV_DIR="$SCRIPT_DIR/.venv"
|
VENV_DIR="$SCRIPT_DIR/.venv"
|
||||||
|
|
||||||
|
# Console + log file. The log contains card keys and request payloads (test
|
||||||
|
# cards) - it is gitignored and must not be committed.
|
||||||
|
LOG_FILE="$SCRIPT_DIR/simple_lastrun.log"
|
||||||
|
exec > >(tee "$LOG_FILE") 2>&1
|
||||||
|
export PYTHONUNBUFFERED=1 # keep the log live: a piped stdout is block-buffered
|
||||||
|
|
||||||
# Auto-detect reader
|
# Auto-detect reader
|
||||||
READER_ARGS=""
|
READER_ARGS=""
|
||||||
if command -v pcscd > /dev/null 2>&1; then
|
if command -v pcscd > /dev/null 2>&1; then
|
||||||
@@ -27,6 +35,7 @@ elif command -v pysim-simple-server &> /dev/null; then
|
|||||||
SERVER="pysim-simple-server"
|
SERVER="pysim-simple-server"
|
||||||
elif [ -f "$SCRIPT_DIR/pysim_simple_server/__main__.py" ]; then
|
elif [ -f "$SCRIPT_DIR/pysim_simple_server/__main__.py" ]; then
|
||||||
echo "Starting pysim-simple-server from source on http://127.0.0.1:8080"
|
echo "Starting pysim-simple-server from source on http://127.0.0.1:8080"
|
||||||
|
echo "Log: simple_lastrun.log (overwritten on each start)."
|
||||||
cd "$SCRIPT_DIR" && python3 -m pysim_simple_server --http-port 8080 $READER_ARGS "$@"
|
cd "$SCRIPT_DIR" && python3 -m pysim_simple_server --http-port 8080 $READER_ARGS "$@"
|
||||||
exit $?
|
exit $?
|
||||||
else
|
else
|
||||||
@@ -37,6 +46,7 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Starting pysim-simple-server on http://127.0.0.1:8080"
|
echo "Starting pysim-simple-server on http://127.0.0.1:8080"
|
||||||
|
echo "Log: simple_lastrun.log (overwritten on each start)."
|
||||||
echo "Press Ctrl+C to stop."
|
echo "Press Ctrl+C to stop."
|
||||||
echo "Extra arguments are passed to the server (e.g. ./start.sh --gsmtap)."
|
echo "Extra arguments are passed to the server (e.g. ./start.sh --gsmtap)."
|
||||||
$SERVER --http-port 8080 $READER_ARGS "$@"
|
$SERVER --http-port 8080 $READER_ARGS "$@"
|
||||||
|
|||||||
Reference in New Issue
Block a user