From 2db3ce6c2e91b81a64916eba47ae34f4d9182702 Mon Sep 17 00:00:00 2001 From: Gareth Coles Date: Sat, 7 Apr 2018 10:10:47 +0100 Subject: Don't create tables on route load by default. * If "FLASK_DEBUG" is in your env vars, tables will be created on route load * If you run a query against a table not declared in database.py, a warning is emitted --- gunicorn_config.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 gunicorn_config.py (limited to 'gunicorn_config.py') diff --git a/gunicorn_config.py b/gunicorn_config.py new file mode 100644 index 00000000..7e17b0cc --- /dev/null +++ b/gunicorn_config.py @@ -0,0 +1,12 @@ +# coding=utf-8 +def when_ready(_server): + """ server hook that only runs when the gunicorn master process loads """ + + print("Creating tables...") + + from pysite.database import RethinkDB + + db = RethinkDB(loop_type=None) + created = db.create_tables() + + print(f"Created {created} tables.") -- cgit v1.2.3