env for failures
Build and Push Docker Images / build-and-push (push) Successful in 27s

This commit is contained in:
2025-07-07 15:04:58 +02:00
parent 34d22118ca
commit cd6390337c
2 changed files with 3 additions and 2 deletions
+1
View File
@@ -23,6 +23,7 @@ ENV TEST_URL="https://www.google.com"
ENV API_KEY="Q7Sd#hhFkyHy*T" ENV API_KEY="Q7Sd#hhFkyHy*T"
ENV TARGET_CONTAINER="puppeteer-api" ENV TARGET_CONTAINER="puppeteer-api"
ENV CHECK_INTERVAL=60 ENV CHECK_INTERVAL=60
ENV MAX_CONSECUTIVE_FAILURES=3
# Create docker group and user with docker group access # Create docker group and user with docker group access
RUN groupadd -g 999 docker || true && \ RUN groupadd -g 999 docker || true && \
+2 -2
View File
@@ -31,6 +31,7 @@ class PuppeteerHealthcheck:
self.api_key = os.getenv('API_KEY', 'Q7Sd#hhFkyHy*T') self.api_key = os.getenv('API_KEY', 'Q7Sd#hhFkyHy*T')
self.target_container = os.getenv('TARGET_CONTAINER', 'puppeteer-api') self.target_container = os.getenv('TARGET_CONTAINER', 'puppeteer-api')
self.check_interval = int(os.getenv('CHECK_INTERVAL', '60')) self.check_interval = int(os.getenv('CHECK_INTERVAL', '60'))
self.max_consecutive_failures = int(os.getenv('MAX_CONSECUTIVE_FAILURES', '3'))
# Initialize Docker client with proper error handling # Initialize Docker client with proper error handling
self.docker_client = self._initialize_docker_client() self.docker_client = self._initialize_docker_client()
@@ -141,7 +142,6 @@ class PuppeteerHealthcheck:
logger.info("Starting Puppeteer API healthcheck service") logger.info("Starting Puppeteer API healthcheck service")
consecutive_failures = 0 consecutive_failures = 0
max_consecutive_failures = 3 # Restart after 3 consecutive failures
while True: while True:
try: try:
@@ -154,7 +154,7 @@ class PuppeteerHealthcheck:
logger.warning(f"Health check failed - consecutive failures: {consecutive_failures}") logger.warning(f"Health check failed - consecutive failures: {consecutive_failures}")
# Restart container if we've had too many consecutive failures # Restart container if we've had too many consecutive failures
if consecutive_failures >= max_consecutive_failures: if consecutive_failures >= self.max_consecutive_failures:
logger.error(f"Health check failed {consecutive_failures} times consecutively - restarting container") logger.error(f"Health check failed {consecutive_failures} times consecutively - restarting container")
if self.restart_container(): if self.restart_container():
consecutive_failures = 0 consecutive_failures = 0