switch to gunicorn

This commit is contained in:
Christoph Reiter
2019-06-09 21:43:43 +02:00
parent ee75ae67a0
commit e6a592bc51
2 changed files with 8 additions and 18 deletions

View File

@@ -3,10 +3,10 @@ FROM debian:buster-slim
RUN apt-get update && apt-get install -y \
python3-requests \
python3-flask \
python3-twisted \
gunicorn3 \
&& rm -rf /var/lib/apt/lists/*
COPY . /app
WORKDIR /app
ENTRYPOINT ["python3", "main.py", "-p", "80"]
ENTRYPOINT ["gunicorn3", "-w1", "-b0.0.0.0:80", "main:app"]
EXPOSE 80

22
main.py
View File

@@ -1222,9 +1222,10 @@ def update_thread() -> None:
time.sleep(UPDATE_INTERVAL)
thread = threading.Thread(target=update_thread)
thread.daemon = True
thread.start()
def start_update_thread():
thread = threading.Thread(target=update_thread)
thread.daemon = True
thread.start()
class SrcInfoPackage(object):
@@ -1302,15 +1303,11 @@ app = Flask(__name__)
app.register_blueprint(packages)
app.jinja_env.undefined = StrictUndefined
start_update_thread()
def main(argv: List[str]) -> Any:
global CACHE_LOCAL
from twisted.internet import reactor
from twisted.web.server import Site
from twisted.web.wsgi import WSGIResource
from twisted.python import log
parser = argparse.ArgumentParser()
parser.add_argument("-c", "--cache", action="store_true",
help="use local repo cache")
@@ -1321,15 +1318,8 @@ def main(argv: List[str]) -> Any:
CACHE_LOCAL = args.cache
print("http://localhost:%d" % args.port)
app.run(port=args.port, debug=args.debug)
if args.debug:
app.debug = True
log.startLogging(sys.stdout)
wsgiResource = WSGIResource(reactor, reactor.getThreadPool(), app)
site = Site(wsgiResource)
reactor.listenTCP(args.port, site)
reactor.run()
if __name__ == "__main__":