Enhance bot functionality and refactor database interactions
- Added `ca-certificates` installation to Dockerfile for improved network security. - Updated health check command in Dockerfile to include better timeout handling. - Refactored `run_helper.py` to implement proper signal handling and logging during shutdown. - Transitioned database operations to an asynchronous model in `async_db.py`, improving performance and responsiveness. - Updated database schema to support new foreign key relationships and optimized indexing for better query performance. - Enhanced various bot handlers to utilize async database methods, improving overall efficiency and user experience. - Removed obsolete database and fix scripts to streamline the project structure.
This commit is contained in:
@@ -29,6 +29,7 @@ ENV PYTHONDONTWRITEBYTECODE=1 \
|
||||
RUN apt-get update && apt-get upgrade -y && apt-get install -y \
|
||||
curl \
|
||||
sqlite3 \
|
||||
ca-certificates \
|
||||
&& rm -rf /var/lib/apt/lists/* \
|
||||
&& apt-get clean
|
||||
|
||||
@@ -56,15 +57,20 @@ RUN sqlite3 /app/database/tg-bot-database.db < /app/database/schema.sql && \
|
||||
# Switch to non-root user
|
||||
USER deploy
|
||||
|
||||
# Health check
|
||||
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
|
||||
CMD curl -f http://localhost:8080/health || exit 1
|
||||
# Health check with better timeout handling
|
||||
HEALTHCHECK --interval=30s --timeout=15s --start-period=10s --retries=5 \
|
||||
CMD curl -f --connect-timeout 5 --max-time 10 http://localhost:8080/health || exit 1
|
||||
|
||||
# Expose metrics port
|
||||
EXPOSE 8080
|
||||
|
||||
# Graceful shutdown
|
||||
# Graceful shutdown with longer timeout
|
||||
STOPSIGNAL SIGTERM
|
||||
|
||||
# Run application
|
||||
CMD ["python", "run_helper.py"]
|
||||
# Set environment variables for better network stability
|
||||
ENV PYTHONUNBUFFERED=1 \
|
||||
PYTHONDONTWRITEBYTECODE=1 \
|
||||
PYTHONHASHSEED=random
|
||||
|
||||
# Run application with proper signal handling
|
||||
CMD ["python", "-u", "run_helper.py"]
|
||||
|
||||
Reference in New Issue
Block a user