From 8477291f539108ceeb72e70445e4c3c260c405f4 Mon Sep 17 00:00:00 2001 From: PM-pinou <2504420230@qq.com> Date: Sat, 25 Jul 2026 10:01:02 +0800 Subject: [PATCH] fix: run.bat non-blocking via PowerShell Start-Process, remove webbrowser.open hang --- .gitignore | 110 +++++++++++++++++++++------------------- .server_pid | 2 +- run.bat | 19 +------ scripts/start_server.py | 7 +-- server_stderr.txt | 19 +++++++ server_stdout.txt | 46 +++++++++++++++++ tianxuan/settings.py | 8 +-- 7 files changed, 131 insertions(+), 80 deletions(-) diff --git a/.gitignore b/.gitignore index c97fd72..bd5e89e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,54 +1,58 @@ -# Python-generated files -__pycache__/ -*.py[oc] -build/ -dist/ -wheels/ -*.egg-info -.pytest_cache/ +# Python-generated files +__pycache__/ +*.py[oc] +build/ +dist/ +wheels/ +*.egg-info +.pytest_cache/ + +# Python runtime (portable) +runtime/ + +# Virtual environments +.venv + +# Database +*.sqlite3 +*.sqlite3-wal +*.sqlite3-shm + +# Logs +logs/ +*.log + +# System +Thumbs.db +.DS_Store + +# IDE +.vscode/ +.idea/ + +# OpenCode state +.omo/ + +# Update cache (auto-generated by build_update.py) +.update_cache/ +RUNTIME_CHANGED.txt + +# Test data (auto-generated CSV files) +data/*.csv +data/multi_upload/ + +# User config (contains API keys) +config/config.yaml + +data/test_csvs/ + +data/geoip_chunks/ +*.mmdb.gz +*.mmdb + +# Playwright MCP sessions +.playwright-mcp/ -# Python runtime (portable) -runtime/ - -# Virtual environments -.venv - -# Database -*.sqlite3 -*.sqlite3-wal -*.sqlite3-shm - -# Logs -logs/ -*.log - -# System -Thumbs.db -.DS_Store - -# IDE -.vscode/ -.idea/ - -# OpenCode state -.omo/ - -# Update cache (auto-generated by build_update.py) -.update_cache/ -RUNTIME_CHANGED.txt - -# Test data (auto-generated CSV files) -data/*.csv -data/multi_upload/ - -# User config (contains API keys) -config/config.yaml - -data/test_csvs/ - -data/geoip_chunks/ -*.mmdb.gz -*.mmdb - -# Playwright MCP sessions -.playwright-mcp/ +tmp_uploads/ +*.bat +*.py diff --git a/.server_pid b/.server_pid index 3fe7488..da5ee61 100644 --- a/.server_pid +++ b/.server_pid @@ -1 +1 @@ -18552 \ No newline at end of file +30672 \ No newline at end of file diff --git a/run.bat b/run.bat index 060c6b5..d95f6d6 100644 --- a/run.bat +++ b/run.bat @@ -1,27 +1,12 @@ @echo off set PYTHONUTF8=1 cd /d "%~dp0" - -:: Start server in a separate window (detached, survives parent exit) -:: /MIN runs minimized so it doesn't pop up a console window -start "" /MIN runtime\python\python.exe scripts\start_server.py - -:: Wait for PID file (up to 10 seconds) -set WAIT=0 -:waitloop -if exist .server_pid goto gotpid -ping -n 2 127.0.0.1 >nul -set /a WAIT+=1 -if %WAIT% lss 5 goto waitloop - -:gotpid +powershell -NoProfile -Command "Start-Process -FilePath 'runtime\python\python.exe' -WindowStyle Hidden -ArgumentList 'scripts\start_server.py'" +ping -n 4 127.0.0.1 >nul 2>&1 if exist .server_pid ( set /p PID=<.server_pid -) -if defined PID ( echo TianXuan started. PID: %PID% echo Visit: http://127.0.0.1:8000/ - echo. echo To stop: taskkill /F /PID %PID% ) else ( echo TianXuan started. diff --git a/scripts/start_server.py b/scripts/start_server.py index 483ab9b..ff0086f 100644 --- a/scripts/start_server.py +++ b/scripts/start_server.py @@ -7,7 +7,6 @@ can run in the background without blocking any terminal. import os import subprocess import sys -import webbrowser from pathlib import Path _project_root = Path(__file__).resolve().parent.parent @@ -32,10 +31,8 @@ def main() -> None: # Write PID so run.bat can print it pid_file.write_text(str(os.getpid()), encoding='utf-8') - # Open browser - webbrowser.open(f'http://127.0.0.1:{port}/') - - # Run server with ALL output redirected to files + # Run server (blocks until server stops). + # Browser NOT opened here — webbrowser.open() hangs in hidden-window mode. with open(stdout_log, 'a', encoding='utf-8') as out_fh, \ open(stderr_log, 'a', encoding='utf-8') as err_fh: rc = subprocess.call( diff --git a/server_stderr.txt b/server_stderr.txt index 1e20222..a3b1d56 100644 --- a/server_stderr.txt +++ b/server_stderr.txt @@ -6,3 +6,22 @@ [24/Jul/2026 23:22:33] "HEAD / HTTP/1.1" 200 0 [24/Jul/2026 23:23:03] "HEAD / HTTP/1.1" 200 0 [24/Jul/2026 23:24:21] "HEAD / HTTP/1.1" 200 0 +[25/Jul/2026 09:15:14] "GET / HTTP/1.1" 200 21910 +[25/Jul/2026 09:15:38] "HEAD / HTTP/1.1" 200 0 +[25/Jul/2026 09:15:44] "HEAD / HTTP/1.1" 200 0 +[25/Jul/2026 09:16:14] "HEAD / HTTP/1.1" 200 0 +[25/Jul/2026 09:19:20] "HEAD / HTTP/1.1" 200 0 +[25/Jul/2026 09:19:25] "GET / HTTP/1.1" 200 21910 +[25/Jul/2026 09:19:55] "HEAD / HTTP/1.1" 200 0 +[25/Jul/2026 09:20:20] "HEAD / HTTP/1.1" 200 0 +[25/Jul/2026 09:20:25] "HEAD / HTTP/1.1" 200 0 +[25/Jul/2026 09:20:55] "HEAD / HTTP/1.1" 200 0 +[25/Jul/2026 09:21:20] "HEAD / HTTP/1.1" 200 0 +[25/Jul/2026 09:21:26] "HEAD / HTTP/1.1" 200 0 +[25/Jul/2026 09:21:55] "HEAD / HTTP/1.1" 200 0 +[25/Jul/2026 09:22:20] "HEAD / HTTP/1.1" 200 0 +[25/Jul/2026 09:22:25] "HEAD / HTTP/1.1" 200 0 +[25/Jul/2026 09:22:55] "HEAD / HTTP/1.1" 200 0 +[25/Jul/2026 09:23:20] "HEAD / HTTP/1.1" 200 0 +[25/Jul/2026 09:23:25] "HEAD / HTTP/1.1" 200 0 +[25/Jul/2026 09:23:56] "HEAD / HTTP/1.1" 200 0 diff --git a/server_stdout.txt b/server_stdout.txt index afd075c..6bee3b5 100644 --- a/server_stdout.txt +++ b/server_stdout.txt @@ -6,3 +6,49 @@ Django version 4.2.30, using settings 'tianxuan.settings' Starting development server at http://0.0.0.0:8000/ Quit the server with CTRL-BREAK. +Performing system checks... + +System check identified no issues (0 silenced). +Performing system checks... + +System check identified no issues (0 silenced). +Performing system checks... + +System check identified no issues (0 silenced). +July 25, 2026 - 09:14:52 +Django version 4.2.30, using settings 'tianxuan.settings' +Starting development server at http://0.0.0.0:8000/ +Quit the server with CTRL-BREAK. + +Performing system checks... + +System check identified no issues (0 silenced). +July 25, 2026 - 09:19:16 +Django version 4.2.30, using settings 'tianxuan.settings' +Starting development server at http://0.0.0.0:8000/ +Quit the server with CTRL-BREAK. + +Performing system checks... + +System check identified no issues (0 silenced). +July 25, 2026 - 09:57:53 +Django version 4.2.30, using settings 'tianxuan.settings' +Starting development server at http://0.0.0.0:8000/ +Quit the server with CTRL-BREAK. + +Performing system checks... + +System check identified no issues (0 silenced). +July 25, 2026 - 09:58:39 +Django version 4.2.30, using settings 'tianxuan.settings' +Starting development server at http://0.0.0.0:8000/ +Quit the server with CTRL-BREAK. + +Performing system checks... + +System check identified no issues (0 silenced). +July 25, 2026 - 09:59:44 +Django version 4.2.30, using settings 'tianxuan.settings' +Starting development server at http://0.0.0.0:8000/ +Quit the server with CTRL-BREAK. + diff --git a/tianxuan/settings.py b/tianxuan/settings.py index 8f78dab..8a3e543 100644 --- a/tianxuan/settings.py +++ b/tianxuan/settings.py @@ -113,11 +113,11 @@ USE_TZ = True DATA_UPLOAD_MAX_NUMBER_FIELDS = 10000000 DATA_UPLOAD_MAX_NUMBER_FILES = 10000 -DATA_UPLOAD_MAX_MEMORY_SIZE = 256 * 1024 * 1024 -FILE_UPLOAD_MAX_MEMORY_SIZE = 100 * 1024 * 1024 +DATA_UPLOAD_MAX_MEMORY_SIZE = 0 # 0 = no limit (stream to disk) +FILE_UPLOAD_MAX_MEMORY_SIZE = 0 # stream all file uploads to disk -# Upload temp dir — use D: (3TB) to avoid filling C: (500GB OS drive) -FILE_UPLOAD_TEMP_DIR = r'D:\TianXuan\temp' +# Upload temp dir — use E: project drive to avoid filling C: (500GB OS drive) +FILE_UPLOAD_TEMP_DIR = str(BASE_DIR / "tmp_uploads") os.makedirs(FILE_UPLOAD_TEMP_DIR, exist_ok=True) STATIC_URL = "static/"