Improve CLI
This commit is contained in:
parent
65ec6d6f9b
commit
c2d2bf49f1
3 changed files with 15 additions and 7 deletions
|
|
@ -40,7 +40,7 @@ GREAT_AI_LOGGING_CONFIG = {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def main() -> None:
|
def serve() -> None:
|
||||||
args = parse_arguments()
|
args = parse_arguments()
|
||||||
should_auto_reload = not _is_in_production_mode(logger=None)
|
should_auto_reload = not _is_in_production_mode(logger=None)
|
||||||
|
|
||||||
|
|
@ -200,10 +200,14 @@ class GreatAIReload(BaseReload):
|
||||||
sock.close()
|
sock.close()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
def main() -> None:
|
||||||
try:
|
try:
|
||||||
main()
|
serve()
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
exit()
|
exit()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(e)
|
logger.error(e)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ from .parse_arguments import parse_arguments
|
||||||
logger = get_logger("large_file")
|
logger = get_logger("large_file")
|
||||||
|
|
||||||
|
|
||||||
def main() -> None:
|
def handle_command() -> None:
|
||||||
parser, args = parse_arguments()
|
parser, args = parse_arguments()
|
||||||
|
|
||||||
large_file = get_class(args)
|
large_file = get_class(args)
|
||||||
|
|
@ -61,11 +61,15 @@ def get_class(args: Namespace) -> Type[LargeFileBase]:
|
||||||
return large_file
|
return large_file
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
def main() -> None:
|
||||||
try:
|
try:
|
||||||
main()
|
handle_command()
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
logger.warning("Exiting")
|
logger.warning("Exiting")
|
||||||
exit()
|
exit()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.exception(e)
|
logger.exception(e)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ def parse_arguments() -> Namespace:
|
||||||
help="the name of the file containing your to-be-served function such as `main.py`\n",
|
help="the name of the file containing your to-be-served function such as `main.py`\n",
|
||||||
)
|
)
|
||||||
|
|
||||||
default_host = "0.0.0.0"
|
default_host = "127.0.0.1"
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--host",
|
"--host",
|
||||||
type=str,
|
type=str,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue