diff --git a/hobbit_core/hobbit/static/bootstrap/shire/configs/gunicorn-logging.ini.jinja2 b/hobbit_core/hobbit/static/bootstrap/shire/configs/gunicorn-logging.ini.jinja2 new file mode 100644 index 0000000..4460ca2 --- /dev/null +++ b/hobbit_core/hobbit/static/bootstrap/shire/configs/gunicorn-logging.ini.jinja2 @@ -0,0 +1,43 @@ +[loggers] +keys=root, gunicorn.error, gunicorn.access + +[handlers] +keys=console, file + + +[formatters] +keys=timedRotatingFormatter + +[formatter_timedRotatingFormatter] +format=%(asctime)s pid:%(process)d - %(levelname)s: %(message)s +datefmt=%Y-%m-%d %H:%M:%S + + +[logger_root] +level=NOTSET +handlers=console, file +qualname=root + +[logger_gunicorn.error] +level=INFO +handlers=console, file +propagate=1 +qualname=gunicorn.error + +[logger_gunicorn.access] +level=INFO +handlers=console, file +propagate=0 +qualname=gunicorn.access + + +[handler_console] +level=INFO +class=StreamHandler +formatter=timedRotatingFormatter +args=(sys.stdout, ) + +[handler_file] +level=DEBUG +class=handlers.TimedRotatingFileHandler +args=('logs/gunicorn.log', 'D', 1, 30) diff --git a/hobbit_core/hobbit/static/bootstrap/shire/docker-compose.yml.jinja2 b/hobbit_core/hobbit/static/bootstrap/shire/docker-compose.yml.jinja2 index f52e167..2f402da 100644 --- a/hobbit_core/hobbit/static/bootstrap/shire/docker-compose.yml.jinja2 +++ b/hobbit_core/hobbit/static/bootstrap/shire/docker-compose.yml.jinja2 @@ -17,7 +17,8 @@ services: networks: - web_nw command: - bash -c "flask db upgrade && gunicorn -k gevent -w 4 -b 0.0.0.0:5000 app.run:app" + bash -c "flask db upgrade && + gunicorn --log-config configs/gunicorn-logging.ini -k gevent -w 4 -b 0.0.0.0:5000 app.run:app" networks: web_nw: diff --git a/hobbit_core/hobbit/static/bootstrap/shire/docs/api.apib.jinja2 b/hobbit_core/hobbit/static/bootstrap/shire/docs/index.apib.jinja2 similarity index 100% rename from hobbit_core/hobbit/static/bootstrap/shire/docs/api.apib.jinja2 rename to hobbit_core/hobbit/static/bootstrap/shire/docs/index.apib.jinja2 diff --git a/setup.py b/setup.py index 1489d36..2db23e4 100644 --- a/setup.py +++ b/setup.py @@ -21,7 +21,7 @@ def gen_data(data_root='hobbit/static/bootstrap'): package_data = gen_data() -assert len(package_data) == 27, \ +assert len(package_data) == 28, \ 'nums of tepl files error, {}'.format(len(package_data)) diff --git a/tests/test_hobbit.py b/tests/test_hobbit.py index ecb2cc0..55e2e08 100644 --- a/tests/test_hobbit.py +++ b/tests/test_hobbit.py @@ -86,7 +86,7 @@ def test_startproject_cmd_example(self): '--echo', 'startproject', '-n', 'haha', '--example', '-p', '1024', ], obj={}) - # start + 27 files + 10 dir + 1 end + empty - assert len(result.output.split('\n')) == 1 + 10 + 27 + 1 + 1 + # start + 28 files + 11 dir + 1 end + empty + assert len(result.output.split('\n')) == 1 + 28 + 11 + 1 + 1 assert result.exit_code == 0 assert 'example.py' in result.output