This commit is contained in:
@@ -23,6 +23,7 @@ ENV TEST_URL="https://www.google.com"
|
||||
ENV API_KEY="Q7Sd#hhFkyHy*T"
|
||||
ENV TARGET_CONTAINER="puppeteer-api"
|
||||
ENV CHECK_INTERVAL=60
|
||||
ENV MAX_CONSECUTIVE_FAILURES=3
|
||||
|
||||
# Create docker group and user with docker group access
|
||||
RUN groupadd -g 999 docker || true && \
|
||||
|
||||
@@ -31,6 +31,7 @@ class PuppeteerHealthcheck:
|
||||
self.api_key = os.getenv('API_KEY', 'Q7Sd#hhFkyHy*T')
|
||||
self.target_container = os.getenv('TARGET_CONTAINER', 'puppeteer-api')
|
||||
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
|
||||
self.docker_client = self._initialize_docker_client()
|
||||
@@ -141,7 +142,6 @@ class PuppeteerHealthcheck:
|
||||
logger.info("Starting Puppeteer API healthcheck service")
|
||||
|
||||
consecutive_failures = 0
|
||||
max_consecutive_failures = 3 # Restart after 3 consecutive failures
|
||||
|
||||
while True:
|
||||
try:
|
||||
@@ -154,7 +154,7 @@ class PuppeteerHealthcheck:
|
||||
logger.warning(f"Health check failed - consecutive failures: {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")
|
||||
if self.restart_container():
|
||||
consecutive_failures = 0
|
||||
|
||||
Reference in New Issue
Block a user