From f3fc214170258c94249e34d2fbf9c3bfcb475ee1 Mon Sep 17 00:00:00 2001 From: Hironsan Date: Mon, 7 Dec 2020 14:50:10 +0900 Subject: [PATCH] Allow user to specify database url --- app/doccano/doccano.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/app/doccano/doccano.py b/app/doccano/doccano.py index 91052e1c..4186cf9c 100644 --- a/app/doccano/doccano.py +++ b/app/doccano/doccano.py @@ -4,14 +4,18 @@ import subprocess def main(): - parser = argparse.ArgumentParser(prog='gfg', description='GfG article demo package.') - parser.add_argument('--username', type=str, default='admin') - parser.add_argument('--password', type=str, default='password') - parser.add_argument('--email', type=str, default='example@example.com') - parser.add_argument('--port', type=int, default=8000) - parser.add_argument('--workers', type=int, default=1) + parser = argparse.ArgumentParser(description='doccano.') + parser.add_argument('--username', type=str, default='admin', help='admin username') + parser.add_argument('--password', type=str, default='password', help='admin password') + parser.add_argument('--email', type=str, default='example@example.com', help='admin email') + parser.add_argument('--port', type=int, default=8000, help='port') + parser.add_argument('--workers', type=int, default=1, help='workers') + parser.add_argument('--database_url', type=str, default='sqlite:///doccano.db', help='data store') args = parser.parse_args() + os.environ.setdefault('DEBUG', 'False') + os.environ.setdefault('DATABASE_URL', args.database_url) + print('Setup Database.') base = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) manage_path = os.path.join(base, 'manage.py') @@ -27,7 +31,6 @@ def main(): '--noinput'], shell=False) print(f'Starting server with port {args.port}.') - os.environ['DEBUG'] = 'False' subprocess.call(['python', manage_path, 'runserver', f'0.0.0.0:{args.port}'])