aboutsummaryrefslogtreecommitdiffstats
path: root/gunicorn_config.py
diff options
context:
space:
mode:
authorGravatar Gareth Coles <[email protected]>2018-04-08 01:13:26 +0100
committerGravatar Gareth Coles <[email protected]>2018-04-08 01:13:26 +0100
commit886fb0b06117e56cc70767424b718c90e2789ef4 (patch)
tree45f21dc888afdb43b4e4e983fc9e199665fbdb57 /gunicorn_config.py
parentFix debug mode indicator (diff)
Fix build
Diffstat (limited to 'gunicorn_config.py')
-rw-r--r--gunicorn_config.py15
1 files changed, 12 insertions, 3 deletions
diff --git a/gunicorn_config.py b/gunicorn_config.py
index e4b66135..eb2f6e1b 100644
--- a/gunicorn_config.py
+++ b/gunicorn_config.py
@@ -1,12 +1,21 @@
# coding=utf-8
-def when_ready(server):
+def when_ready(server=None):
""" server hook that only runs when the gunicorn master process loads """
- server.log.info("Creating tables...")
+ if server:
+ output = server.log.info
+ else:
+ output = print
+
+ output("Creating tables...")
from pysite.database import RethinkDB
db = RethinkDB(loop_type=None)
created = db.create_tables()
- server.log.info(f"Created {created} tables.")
+ output(f"Created {created} tables.")
+
+
+if __name__ == "__main__":
+ when_ready()