This repository has been archived by the owner on Jun 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* adding pidfile support for monit deployment * http content gzip * .. * bugfixes * tweaking reqs * tweaking compression for httpd * fixing some store queues * bugfixes * cleaning up health checks * cleaning up health checks * adding gevent and gunicorn deps * bugfix to filter * requirements update * fixing vagrant for es tests * fixing elasticsearch tests * adding flag to vagrantfile
- Loading branch information
Showing
16 changed files
with
211 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
from flask import current_app | ||
from cifsdk.client.zeromq import ZMQ as Client | ||
from cif.constants import ROUTER_ADDR | ||
from cifsdk.exceptions import TimeoutError, AuthError | ||
from ..common import jsonify_unauth, jsonify_unknown, jsonify_success | ||
from flask.views import MethodView | ||
import os | ||
import gc | ||
from flask import request | ||
from flask_limiter.util import get_remote_address | ||
|
||
HTTPD_TOKEN = os.getenv('CIF_HTTPD_TOKEN', False) | ||
|
||
|
||
class HealthAPI(MethodView): | ||
def get(self): | ||
|
||
# feeds get large need to force some cleanup | ||
gc.collect() | ||
|
||
if get_remote_address() != request.access_route[-1]: | ||
return jsonify_unauth() | ||
|
||
if not HTTPD_TOKEN: | ||
return jsonify_success() | ||
|
||
remote = ROUTER_ADDR | ||
if current_app.config.get('CIF_ROUTER_ADDR'): | ||
remote = current_app.config['CIF_ROUTER_ADDR'] | ||
|
||
try: | ||
r = Client(remote, HTTPD_TOKEN).ping() | ||
r = Client(remote, HTTPD_TOKEN).indicators_search({'indicator': 'example.com', 'nolog': '1'}) | ||
r = True | ||
|
||
except TimeoutError: | ||
return jsonify_unknown(msg='timeout', code=408) | ||
|
||
except AuthError: | ||
return jsonify_unauth() | ||
|
||
if not r: | ||
return jsonify_unknown(503) | ||
|
||
return jsonify_success() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.