Up
This commit is contained in:
+24
-19
@@ -33,25 +33,30 @@ class DBConnector:
|
|||||||
pool_min: int = 5,
|
pool_min: int = 5,
|
||||||
pool_recycle: int = 3600,
|
pool_recycle: int = 3600,
|
||||||
):
|
):
|
||||||
self._pool = PooledDB(
|
# PooledDB parameters
|
||||||
creator=pymysql,
|
pool_config = {
|
||||||
maxconnections=pool_size,
|
"creator": pymysql,
|
||||||
mincached=pool_min,
|
"maxconnections": pool_size,
|
||||||
maxcached=pool_size,
|
"mincached": pool_min,
|
||||||
maxusage=200,
|
"maxcached": pool_size,
|
||||||
blocking=True,
|
"maxusage": 200,
|
||||||
max_idle_time=pool_recycle,
|
"blocking": True,
|
||||||
connection_timeout=10,
|
}
|
||||||
charset="utf8mb4",
|
|
||||||
cursorclass=pymysql.cursors.DictCursor,
|
# PyMySQL connection parameters
|
||||||
host=host,
|
connection_params = {
|
||||||
port=port,
|
"host": host,
|
||||||
database=database,
|
"port": port,
|
||||||
user=user,
|
"database": database,
|
||||||
password=password,
|
"user": user,
|
||||||
read_timeout=30,
|
"password": password,
|
||||||
write_timeout=30,
|
"charset": "utf8mb4",
|
||||||
)
|
"cursorclass": pymysql.cursors.DictCursor,
|
||||||
|
"read_timeout": 30,
|
||||||
|
"write_timeout": 30,
|
||||||
|
}
|
||||||
|
|
||||||
|
self._pool = PooledDB(**pool_config, **connection_params)
|
||||||
logger.info(
|
logger.info(
|
||||||
"DB pool initialized: host=%s db=%s pool_size=%d min=%d",
|
"DB pool initialized: host=%s db=%s pool_size=%d min=%d",
|
||||||
host, database, pool_size, pool_min,
|
host, database, pool_size, pool_min,
|
||||||
|
|||||||
@@ -14,8 +14,6 @@ import logging.handlers
|
|||||||
import sys
|
import sys
|
||||||
from datetime import datetime, timezone
|
from datetime import datetime, timezone
|
||||||
|
|
||||||
from python_json_logger import json_formatter
|
|
||||||
|
|
||||||
|
|
||||||
def setup_logging(
|
def setup_logging(
|
||||||
level: str = "INFO",
|
level: str = "INFO",
|
||||||
|
|||||||
+3
-3
@@ -1,6 +1,5 @@
|
|||||||
# Base image: CUDA 11.8 runtime on Ubuntu 22.04
|
# Base image: CUDA 11.8 runtime on Ubuntu 22.04
|
||||||
#FROM nvidia/cuda:11.8.0-runtime-ubuntu22.04
|
FROM nvidia/cuda:11.8.0-runtime-ubuntu22.04
|
||||||
FROM nvidia/cuda:13.3.1-cudnn-runtime-ubuntu22.04
|
|
||||||
|
|
||||||
# Avoid interactive prompts during build
|
# Avoid interactive prompts during build
|
||||||
ENV DEBIAN_FRONTEND=noninteractive
|
ENV DEBIAN_FRONTEND=noninteractive
|
||||||
@@ -36,7 +35,8 @@ RUN groupadd -g 1000 appuser && \
|
|||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Create necessary directories
|
# Create necessary directories
|
||||||
RUN mkdir -p /scratch /models /data/training /data/output /logs
|
RUN mkdir -p /scratch /models /data/training /data/output /logs && \
|
||||||
|
chown -R appuser:appuser /app /scratch /models /data /logs
|
||||||
|
|
||||||
# Copy requirements first for better caching
|
# Copy requirements first for better caching
|
||||||
COPY worker/requirements.txt /app/requirements.txt
|
COPY worker/requirements.txt /app/requirements.txt
|
||||||
|
|||||||
Reference in New Issue
Block a user