Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
F4ever committed Oct 3, 2023
1 parent 34a1c95 commit 77eb924
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/metrics/healthcheck_server.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
import logging
import threading
from datetime import datetime, timedelta
from http.server import SimpleHTTPRequestHandler, HTTPServer

import requests
from requests.exceptions import ConnectionError

from src import variables
from src.variables import MAX_CYCLE_LIFETIME_IN_SECONDS


_last_pulse = datetime.now()
logger = logging.getLogger(__name__)


def pulse():
"""Ping to healthcheck server that application is ok"""
requests.get(f'http://localhost:{variables.HEALTHCHECK_SERVER_PORT}/pulse/', timeout=10)
try:
requests.get(f'http://localhost:{variables.HEALTHCHECK_SERVER_PORT}/pulse/', timeout=10)
except ConnectionError:
logger.warning({'Healthcheck server is not responding.'})


class PulseRequestHandler(SimpleHTTPRequestHandler):
Expand Down

0 comments on commit 77eb924

Please sign in to comment.