CLI: add --help to print usage and env-based configuration hints
This commit is contained in:
9
run.py
9
run.py
@@ -1,6 +1,7 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
import os
|
import os
|
||||||
import logging
|
import logging
|
||||||
|
import sys
|
||||||
|
|
||||||
from server.server import GameServer
|
from server.server import GameServer
|
||||||
from server.config import ServerConfig
|
from server.config import ServerConfig
|
||||||
@@ -70,6 +71,14 @@ async def run_webtransport():
|
|||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
try:
|
try:
|
||||||
|
if any(a in ("-h", "--help") for a in sys.argv[1:]):
|
||||||
|
print(
|
||||||
|
"Usage: python run.py [--mode mem|quic|wt] [--log-level LEVEL] [--run-seconds N]\n"
|
||||||
|
" TLS (for wt/quic): set QUIC_CERT/QUIC_KEY or WT_CERT/WT_KEY env vars\n"
|
||||||
|
" WT static server (MODE=wt): STATIC=1 [STATIC_HOST/PORT/ROOT]\n"
|
||||||
|
"Examples:\n MODE=wt QUIC_CERT=cert.pem QUIC_KEY=key.pem python run.py\n MODE=mem python run.py"
|
||||||
|
)
|
||||||
|
sys.exit(0)
|
||||||
# Logging setup
|
# Logging setup
|
||||||
level = os.environ.get("LOG_LEVEL", "INFO").upper()
|
level = os.environ.get("LOG_LEVEL", "INFO").upper()
|
||||||
logging.basicConfig(level=getattr(logging, level, logging.INFO), format="[%(asctime)s] %(levelname)s: %(message)s")
|
logging.basicConfig(level=getattr(logging, level, logging.INFO), format="[%(asctime)s] %(levelname)s: %(message)s")
|
||||||
|
|||||||
Reference in New Issue
Block a user