fix: add startup hints for port and state source (fixes #31)

- Backend: print STAR_BACKEND_PORT hint so users can change port without
  editing app.py (e.g. when 18791 is already in use).
- office-agent-push.py: print state file source and LOCAL_STATUS_URL at
  startup so users can verify path and URL when state does not update.

Made-with: Cursor
This commit is contained in:
RoomWithOutRoof 2026-03-06 02:34:00 +08:00
parent 8d36ad5267
commit 51172ee202
2 changed files with 15 additions and 0 deletions

View file

@ -2053,6 +2053,10 @@ if __name__ == "__main__":
print("=" * 50)
print(f"State file: {STATE_FILE}")
print(f"Listening on: http://0.0.0.0:{backend_port}")
if backend_port != 18791:
print(f"(Port override: set STAR_BACKEND_PORT to change; current: {raw_port})")
else:
print("(Set STAR_BACKEND_PORT to use a different port, e.g. 3009)")
mode = "production" if is_production_mode() else "development"
print(f"Mode: {mode}")
if is_production_mode():

View file

@ -262,6 +262,17 @@ def do_push(local, status_data):
def main():
local = load_local_state()
# Startup hint for state source and URL (helps with port/state issues, e.g. issue #31)
if LOCAL_STATE_FILE:
print(f"State file: {LOCAL_STATE_FILE}")
else:
first_existing = next((p for p in DEFAULT_STATE_CANDIDATES if p and os.path.exists(p)), None)
if first_existing:
print(f"State file (auto): {first_existing}")
else:
print("State file: auto-discover (set OFFICE_LOCAL_STATE_FILE if state not found)")
print(f"Local status URL: {LOCAL_STATUS_URL} (set OFFICE_LOCAL_STATUS_URL if backend uses another port)")
# 先确认配置是否齐全
if not JOIN_KEY or not AGENT_NAME:
print("❌ 请先在脚本开头填入 JOIN_KEY 和 AGENT_NAME")