-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrunserver.py
60 lines (47 loc) · 1.4 KB
/
runserver.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import logging
import logging.config
import os
import yaml
from application import app
loggingyaml = '''
version: 1
disable_existing_loggers: false
formatters:
default:
format: '%(asctime)s %(levelname)s %(name)s %(message)s'
# jsonFormat:
# (): pythonjsonlogger.jsonlogger.JsonFormatter
# format: '%(asctime) %(created) %(filename) %(funcName) %(levelname) %(levelno) %(lineno) %(module) %(msecs) %(message) %(name) %(pathname) %(process) %(processName) %(relativeCreated) %(thread) %(threadName)'
filters: []
handlers:
# loggly:
# class: loggly.handlers.HTTPSHandler
# formatter: jsonFormat
# url: 'https://logs-01.loggly.com/inputs/''' + os.environ.get('SERVICES_LOGGLY_TOKEN', '') + '''/tag/python'
stderr:
class: logging.StreamHandler
formatter: default
stream: ext://sys.stderr
# loggers:
# sqlalchemy.engine:
# propagate: False
# level: WARNING
# handlers: [loggly,]
# sqlalchemy.engine.base.Engine.test:
# level: WARNING
# propagate: False
# handlers: [loggly,]
# sqlalchemy.pool:
# level: WARNING
# sqlalchemy.orm.unitofwork:
# level: WARNING
root:
level: DEBUG
handlers: [stderr]
'''
# run the application!
if __name__ == '__main__':
logging.config.dictConfig(yaml.load(loggingyaml))
# Bind to PORT if defined, otherwise default to 5000.
port = int(os.environ.get('PORT', 5000))
app.run(host='0.0.0.0', port=port)