aboutsummaryrefslogtreecommitdiffstats
path: root/gunicorn_config.py
diff options
context:
space:
mode:
authorGravatar Gareth Coles <[email protected]>2018-04-07 10:10:47 +0100
committerGravatar Gareth Coles <[email protected]>2018-04-07 10:10:47 +0100
commit2db3ce6c2e91b81a64916eba47ae34f4d9182702 (patch)
tree26e22969e56caae7d18d03be3606bb9f3fbdce4a /gunicorn_config.py
parentFlake8 (diff)
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
Diffstat (limited to 'gunicorn_config.py')
-rw-r--r--gunicorn_config.py12
1 files changed, 12 insertions, 0 deletions
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.")