blob: 6ab52451ca003871bb125db9c9bd34d049b1ea63 [file] [log] [blame]
import argparse
import logging
import multiprocessing
from gevent import monkey
monkey.patch_all()
import grpc.experimental.gevent as grpc_gevent
grpc_gevent.init_gevent()
from werkzeug.contrib.fixers import ProxyFix
import gunicorn.app.base
from bgpwtf.cccampix.frontend.frontend import create_app
class StandaloneApplication(gunicorn.app.base.BaseApplication):
def __init__(self, app, options=None):
self.options = options or {}
self.application = app
super(StandaloneApplication, self).__init__()
def load_config(self):
config = dict(
[
(key, value)
for key, value in options.items()
if key in self.cfg.settings and value is not None
]
)
for key, value in config.items():
self.cfg.set(key.lower(), value)
def load(self):
return self.application
parser = argparse.ArgumentParser(description="Run the IXP frontend")
parser.add_argument("--flask_secret", required=True, help="Flask App Secret")
parser.add_argument("--workers", type=int, default=4, help="Number of gunicorn workers to run")
parser.add_argument("--listen", default="0.0.0.0:8080", help="Listen address")
parser.add_argument("--verifier", default="127.0.0.1:4200", help="Address of verifier service")
if __name__ == '__main__':
args = parser.parse_args()
options = {
"bind": args.listen,
"workers": args.workers,
"sendfile": False,
"timeout": 240,
}
config = {
"verifier": args.verifier,
}
app = create_app(config)
app.secret_key = args.flask_secret
app = ProxyFix(app)
StandaloneApplication(app, options).run()