diff --git a/gunicorn.conf.py b/gunicorn.conf.py index d79010c..5fcfd58 100644 --- a/gunicorn.conf.py +++ b/gunicorn.conf.py @@ -2,7 +2,7 @@ import multiprocessing # Bind address — change to a Unix socket for nginx proxy: # bind = 'unix:/tmp/magic.sock' -bind = '0.0.0.0:5000' +# bind = '0.0.0.0:5000' # One worker per CPU core, +1. Keep at 2 minimum for SQLite (WAL mode handles # concurrent reads; writes are serialised at the SQLite layer). diff --git a/production.py b/production.py index 681d966..77f892b 100644 --- a/production.py +++ b/production.py @@ -237,9 +237,9 @@ def _build_parser() -> argparse.ArgumentParser: sub.required = True def _add_server_args(p: argparse.ArgumentParser) -> None: - p.add_argument('--host', default='0.0.0.0', metavar='HOST', + p.add_argument('--host', default=None, metavar='HOST', help='Bind address (default: 0.0.0.0)') - p.add_argument('--port', default=5000, type=int, metavar='PORT', + p.add_argument('--port', default=None, type=int, metavar='PORT', help='Bind port (default: 5000)') p.add_argument('--workers', default=None, type=int, metavar='N', help='Worker processes (default: cpu_count + 1, min 2)') @@ -283,16 +283,8 @@ def main() -> None: # args.host and args.port always have values because of 'default' in ArgumentParser. # We'll re-parse or check the sys.argv. - host = default_host - port = default_port - - # Simple check: if '--host' or '--port' is in sys.argv, use the arg value. - # Otherwise, use the config value. - if '--host' in sys.argv: - host = args.host - if '--port' in sys.argv: - port = args.port - + host = args.host or default_host or '0.0.0.0' + port = args.port or default_port or 5000 workers = getattr(args, 'workers', None) or default_workers if args.command == 'start':