Refactor grpc-balancer to use Gunicorn and update playbook.yml for deployment

- Replaced the SSL server implementation in grpc-balancer.py with Gunicorn for improved performance and scalability.
- Updated playbook.yml to use Gunicorn for starting the grpc-balancer service, including SSL certificate configuration.
- Removed the waitress dependency in favor of Gunicorn, streamlining the application setup.
This commit is contained in:
vvzvlad 2025-01-20 19:32:16 +03:00
parent e40e14dea5
commit 64d57407e0
2 changed files with 3 additions and 10 deletions

View File

@ -318,11 +318,4 @@ if __name__ == '__main__':
upload_thread = threading.Thread(target=upload_stats_to_grist, daemon=True, args=(grist_callback,))
upload_thread.start()
from waitress import serve
import ssl
ssl_context = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH)
ssl_context.load_cert_chain('/root/node/cert.pem', '/root/node/key.pem')
logging.info(f"Starting SSL server on port {PORT}")
serve(app, host='0.0.0.0', port=PORT, threads=MAX_WORKERS, connection_limit=1000, _ssl_context=ssl_context)
app.run(host='0.0.0.0', port=PORT)

View File

@ -200,7 +200,7 @@
- grist-api
- flask
- requests
- waitress
- gunicorn
extra_args: --break-system-packages
- name: Create SSL certificate for grpcbalancer
@ -229,7 +229,7 @@
Type=simple
User=root
WorkingDirectory={{ ansible_env.HOME }}/node
ExecStart=/usr/bin/python3 {{ ansible_env.HOME }}/node/grpc-balancer.py
ExecStart=/usr/local/bin/gunicorn --certfile=/root/node/cert.pem --keyfile=/root/node/key.pem -b 0.0.0.0:5000 grpc-balancer:app
Restart=always
RestartSec=2