From 584aee13da59fe8d0dfcd7ea7671fdc18af0eaf1 Mon Sep 17 00:00:00 2001 From: Bui Date: Thu, 24 Mar 2022 16:09:01 +0000 Subject: [PATCH] more debug options --- app.py | 10 +++++++++- server.py | 3 ++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/app.py b/app.py index 4c6c3e9..a899b68 100644 --- a/app.py +++ b/app.py @@ -1,5 +1,6 @@ #!/usr/bin/env python3 +import argparse import base64 import bcrypt import hashlib @@ -23,6 +24,12 @@ from ffmpy import FFmpeg from pymongo import MongoClient from redis import Redis +parser = argparse.ArgumentParser(description='Run the taiko-web development server.') +parser.add_argument('port', type=int, metavar='PORT', nargs='?', default=34801, help='Port to listen on.') +parser.add_argument('-b', '--bind-address', default='localhost', help='Bind server to address.') +parser.add_argument('-d', '--debug', action='store_true', help='Enable debug mode.') +args = parser.parse_args() + def take_config(name, required=False): if hasattr(config, name): return getattr(config, name) @@ -717,4 +724,5 @@ if __name__ == '__main__': def send_assets(path): return send_from_directory('public/assets', path) - app.run(port=34801) + app.run(host=args.bind_address, port=args.port, debug=args.debug) + diff --git a/server.py b/server.py index 5f4016e..65d0fdf 100644 --- a/server.py +++ b/server.py @@ -9,6 +9,7 @@ import sys parser = argparse.ArgumentParser(description='Run the taiko-web multiplayer server.') parser.add_argument('port', type=int, metavar='PORT', nargs='?', default=34802, help='Port to listen on.') +parser.add_argument('-b', '--bind-address', default='localhost', help='Bind server to address.') parser.add_argument('-o', '--allow-origin', action='append', help='Limit incoming connections to the specified origin. Can be specified multiple times.') args = parser.parse_args() @@ -382,7 +383,7 @@ port = args.port print('Starting server on port %d' % port) loop = asyncio.get_event_loop() tasks = asyncio.gather( - websockets.serve(connection, "localhost", port, origins=args.allow_origin) + websockets.serve(connection, args.bind_address, port, origins=args.allow_origin) ) try: loop.run_until_complete(tasks)