Exemplo n.º 1
0
    def get_service_status(self, service):
        try:
            result = self.redis.get(service.lower())
        except ConnectionError as ce:
            logger.warning("Got a timeout error trying to get_service_status from Redis for %s" % service , exc_info=True)
            result = None

        if result is None:
            return "Unknown"
        else:
            return str2bool(result.lower())
Exemplo n.º 2
0
    def get_result(self, name, server):
        try:
            result = self.redis.get('%s|%s', name.lower(), server.lower())
        except ConnectionError as ce:
            logger.warning("Got a timeout error trying to get_result from Redis for %s:%s " % (name, server), exc_info=True)
            result = None

        if result is None:
            return "Unknown"
        else:
            return str2bool(result.lower())
Exemplo n.º 3
0
    def dispatch(self, request, *args, **kwargs):
        health_check_results = None
        if str2bool(request.GET.get('details', "False")):
            if general_config().health_check is not None:
                health_check_results = {}
                for endpoint_url in self.endpoints:
                    endpoint = self.endpoints.get(endpoint_url)
                    if endpoint is not None:
                        health_check_results[endpoint.get('name').lower()] = general_config().health_check.get_service_status(endpoint.get('name').lower())

        res = {"success": True,
           "number_of_endpoints": len(self.endpoints),
           "domain_name": self.domain_name,
           "version": __version__,
           "startup_time": self.startup_time }

        if health_check_results is not None:
            res['endpoint_statuses'] = health_check_results

        return HttpResponse(json.dumps(res, default=dthandler), content_type="application/json")
    "host": redis_url.hostname,
    "port": redis_url.port,
    "db": 0,
    "password": redis_url.password
}


CACHE_REDIS = {
    "host": redis_url.hostname,
    "port": redis_url.port,
    "db": 1,
    "password": redis_url.password
}


debug_mode = str2bool(os.environ.get('DEBUG', "False"))
DEBUG = debug_mode

LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'formatters': {
        'standard': {
            'format': '%(asctime)s [%(levelname)s] %(name)s: %(message)s'
        },
        },
    'filters': {
        'require_debug_false': {
            '()': 'django.utils.log.RequireDebugFalse'
        }
    },