Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed standalone healthcheck #328

Merged
merged 1 commit into from
Oct 25, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions splunk_eventgen/eventgen_api_server/eventgen_server_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ def __init__(self, eventgen, redis_connector, host, mode='standalone'):
self.host = host

self.interval = 0.01
if mode != 'standalone':
self.mode = mode
if self.mode != 'standalone':
self.redis_connector = redis_connector
self._channel_listener()
self.logger.info("Initialized the channel listener. Cluster mode ready.")
Expand Down Expand Up @@ -433,13 +434,16 @@ def reset(self):

def healthcheck(self):
response = {}
try:
self.redis_connector.pubsub.check_health()
response['message'] = "Connections are healthy"
except Exception as e:
self.logger.error("Connection to Redis failed: {}, re-registering".format(str(e)))
self.redis_connector.register_myself(hostname=self.host, role="server")
response['message'] = "Connections unhealthy - re-established connections"
if self.mode != 'standalone':
try:
self.redis_connector.pubsub.check_health()
response['message'] = "Connections are healthy"
except Exception as e:
self.logger.error("Connection to Redis failed: {}, re-registering".format(str(e)))
self.redis_connector.register_myself(hostname=self.host, role="server")
response['message'] = "Connections unhealthy - re-established connections"
else:
response['message'] = "Standalone {} is healthy".format(self.host)
return response

def set_bundle(self, url):
Expand Down