added gunicorn and updated to the last version of server monitorizare

This commit is contained in:
ske087
2026-06-07 21:28:09 +03:00
parent 0aefadbfd8
commit b97372f74d
35 changed files with 2098 additions and 255 deletions
+1 -1
View File
@@ -22,4 +22,4 @@ ENV PYTHONUNBUFFERED=1
EXPOSE 5000
CMD ["python", "run.py"]
CMD ["gunicorn", "-b", "0.0.0.0:5000", "-w", "4", "--timeout", "120", "run:app"]
+18
View File
@@ -1,6 +1,9 @@
from flask_sqlalchemy import SQLAlchemy
from flask_migrate import Migrate
from flask_login import LoginManager
from sqlalchemy import event
from sqlalchemy.engine import Engine
import sqlite3
db = SQLAlchemy()
migrate = Migrate()
@@ -8,3 +11,18 @@ login_manager = LoginManager()
login_manager.login_view = 'auth.login'
login_manager.login_message = 'Please log in to access this page.'
login_manager.login_message_category = 'warning'
@event.listens_for(Engine, "connect")
def _set_sqlite_pragma(dbapi_connection, connection_record):
"""Enable WAL mode and sane concurrency settings for SQLite.
WAL lets readers and writers operate concurrently, which prevents
'database is locked' errors when running under multi-worker Gunicorn.
"""
if isinstance(dbapi_connection, sqlite3.Connection):
cursor = dbapi_connection.cursor()
cursor.execute("PRAGMA journal_mode=WAL")
cursor.execute("PRAGMA busy_timeout=5000")
cursor.execute("PRAGMA synchronous=NORMAL")
cursor.close()
+1
View File
@@ -14,3 +14,4 @@ cryptography==42.0.8
requests==2.32.3
httpx[http2]
docxtpl
gunicorn==23.0.0
+1 -1
View File
@@ -5,4 +5,4 @@ app = create_app(os.environ.get('FLASK_ENV', 'development'))
if __name__ == '__main__':
port = int(os.environ.get('PORT', 5003))
app.run(host='127.0.0.1', port=port)
app.run(host='0.0.0.0', port=port)