fix: run.bat non-blocking via PowerShell Start-Process, remove webbrowser.open hang

This commit is contained in:
PM-pinou
2026-07-25 10:01:02 +08:00
parent 464642288e
commit 8477291f53
7 changed files with 131 additions and 80 deletions
+57 -53
View File
@@ -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
+1 -1
View File
@@ -1 +1 @@
18552
30672
+2 -17
View File
@@ -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.
+2 -5
View File
@@ -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(
+19
View File
@@ -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
+46
View File
@@ -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.
+4 -4
View File
@@ -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/"