2020-08-13 17:48:26 +00:00
|
|
|
#!/usr/bin/python3
|
2020-10-15 16:11:27 +00:00
|
|
|
import sys
|
2020-09-03 15:56:42 +00:00
|
|
|
import argparse
|
2020-10-15 16:11:27 +00:00
|
|
|
import bjoern
|
2019-01-13 19:07:46 +00:00
|
|
|
|
|
|
|
|
2020-10-15 16:11:27 +00:00
|
|
|
def install(arguments):
|
|
|
|
from flaschengeist.app import create_app, install_all
|
|
|
|
app = create_app()
|
|
|
|
with app.app_context():
|
|
|
|
install_all()
|
|
|
|
|
2020-09-03 15:56:42 +00:00
|
|
|
|
2020-10-15 16:11:27 +00:00
|
|
|
def run(arguments):
|
|
|
|
from flaschengeist.app import create_app
|
2020-09-03 15:56:42 +00:00
|
|
|
app = create_app()
|
2020-10-15 16:11:27 +00:00
|
|
|
with app.app_context():
|
|
|
|
if arguments.debug:
|
|
|
|
app.run(arguments.host, arguments.port, debug=True)
|
2020-10-03 23:29:49 +00:00
|
|
|
else:
|
2020-10-15 16:11:27 +00:00
|
|
|
bjoern.run(app, arguments.host, arguments.port, reuse_port=True)
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
# create the top-level parser
|
|
|
|
parser = argparse.ArgumentParser()
|
|
|
|
subparsers = parser.add_subparsers(help='sub-command help', dest="sub_command")
|
|
|
|
subparsers.required = True
|
|
|
|
parser_run = subparsers.add_parser('run', help='run flaschengeist')
|
|
|
|
parser_run.set_defaults(func=run)
|
|
|
|
parser_run.add_argument("--host", help="set hostname to listen on", default="127.0.0.1")
|
|
|
|
parser_run.add_argument("--port", help="set port to listen on", type=int, default=5000)
|
|
|
|
parser_run.add_argument("--debug", help="run in debug mode", action="store_true")
|
|
|
|
parser_install = subparsers.add_parser('install', help='run database setup for flaschengeist and all installed plugins')
|
|
|
|
parser_install.set_defaults(func=install)
|
|
|
|
|
|
|
|
args = parser.parse_args()
|
|
|
|
args.func(args)
|