Refactor Docker setup and enhance MongoDB connection handling
- Updated Dockerfile to use Gunicorn for serving the Flask application instead of the default Python command. - Modified docker-compose.yml to set memory limits and reservations for MongoDB and the web service. - Enhanced main.py with improved MongoDB connection management using a thread-safe singleton pattern and added environment variable configurations for connection pooling. - Introduced new utility functions for system monitoring, including uptime, load averages, and disk usage. - Added backup and restore functionality for instances, including routes for exporting and importing backups. - Removed the live monitor section from admin_instances.html and updated admin_system.html to include a comprehensive server management dashboard with KPIs and usage charts. - Added a new gunicorn configuration file for better performance tuning. - Updated requirements.txt to include Gunicorn as a dependency.
This commit is contained in:
@@ -2,6 +2,8 @@ services:
|
||||
mongodb:
|
||||
image: mongo:7
|
||||
restart: unless-stopped
|
||||
mem_limit: 512m
|
||||
mem_reservation: 256m
|
||||
environment:
|
||||
MONGO_INITDB_DATABASE: Invario_Website
|
||||
volumes:
|
||||
@@ -23,6 +25,12 @@ services:
|
||||
environment:
|
||||
MONGO_URI: mongodb://mongodb:27017
|
||||
MONGO_DB_NAME: Invario_Website
|
||||
MONGO_MAX_POOL_SIZE: ${MONGO_MAX_POOL_SIZE:-24}
|
||||
MONGO_MIN_POOL_SIZE: ${MONGO_MIN_POOL_SIZE:-0}
|
||||
MONGO_MAX_IDLE_MS: ${MONGO_MAX_IDLE_MS:-60000}
|
||||
MONGO_CONNECT_TIMEOUT_MS: ${MONGO_CONNECT_TIMEOUT_MS:-1500}
|
||||
MONGO_SOCKET_TIMEOUT_MS: ${MONGO_SOCKET_TIMEOUT_MS:-30000}
|
||||
MONGO_WAIT_QUEUE_TIMEOUT_MS: ${MONGO_WAIT_QUEUE_TIMEOUT_MS:-2000}
|
||||
SESSION_COOKIE_SECURE: ${SESSION_COOKIE_SECURE:-0}
|
||||
JWT_SECRET_KEY: change-this-in-production
|
||||
INSTANCE_PROVISION_SCRIPT: /app/provision_instance.sh
|
||||
@@ -40,6 +48,8 @@ services:
|
||||
- /etc/nginx/certs:/etc/nginx/certs
|
||||
ports:
|
||||
- "4999:4999"
|
||||
mem_limit: 384m
|
||||
mem_reservation: 192m
|
||||
|
||||
volumes:
|
||||
mongo_data:
|
||||
|
||||
Reference in New Issue
Block a user