-
Notifications
You must be signed in to change notification settings - Fork 3
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
Add connection health check #152
Conversation
Hardcoded value
src/howitz/endpoints.py
Outdated
@main.route('/test_connection') | ||
def test_conn(): | ||
is_connection_ok = test_zino_connection() | ||
caller_id = request.headers.get('HX-Target', None) | ||
if not is_connection_ok: | ||
current_app.logger.debug('Connection test failed showing error appbar') | ||
return render_template('components/feedback/connection-status-bar/error-appbar-content.html', | ||
error_message="Connection to Zino server is lost") | ||
if caller_id == 'connection-error-content': # If connection should be restored after error | ||
current_app.logger.debug('Connection test OK, caller ID %s', caller_id) | ||
reconnect_to_zino() | ||
return render_template('components/feedback/connection-status-bar/success-appbar-content.html') | ||
else: | ||
current_app.logger.debug('Connection test OK, caller ID %s', caller_id) | ||
return render_template('components/feedback/connection-status-bar/success-appbar-content.html') | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Polish for later: a link zabbix and similar can visit to check health. Need only return http status codes: 200 or 50x.
src/howitz/error_handlers.py
Outdated
is_connection_ok = test_zino_connection() | ||
if is_connection_ok is not False: # Both True or None are OK | ||
reconnect_to_zino() | ||
short_err_msg = 'Temporarily lost connection to Zino server, please retry your action' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uuuh.. reconnect if the connection is ok? Did you mean if is_connection_ok is False:
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is deliberate. This code is in handle_lost_connection
, so the connection was down when it was called. Here we check if connection is back again. reconnect_to_zino
means "ensure a clean reconnect procedure", I will add some comments with explanations
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks good, will test
Closes #145