mirror of
https://github.com/chanzuckerberg/cellxgene.git
synced 2026-09-25 19:08:11 +08:00
This splits the backend into two parts: the local backend for desktop cellxgene and the AWS backend for hosted cellxgene. The local backend is in local_server while the hosted remains in server. The general idea is to copy everything from server to local_server, pull unneeded stuff out of local_server, and keep server as-is for this PR. Not touching server means all the infra and deployment code will continue working just as it did before so we can make those changes incrementally.
34 lines
1.0 KiB
Python
34 lines
1.0 KiB
Python
from http import HTTPStatus
|
|
from flask import make_response, jsonify
|
|
|
|
from local_server import __version__ as cellxgene_version
|
|
from local_server.common.data_locator import DataLocator
|
|
|
|
|
|
def _is_accessible(path, config):
|
|
if path is None:
|
|
return True
|
|
|
|
try:
|
|
dl = DataLocator(path, region_name=config.data_locator__s3__region_name)
|
|
return dl.exists()
|
|
except RuntimeError:
|
|
return False
|
|
|
|
|
|
def health_check(config):
|
|
"""
|
|
simple health check - return HTTP response.
|
|
See https://tools.ietf.org/id/draft-inadarei-api-health-check-01.html
|
|
"""
|
|
health = {"status": None, "version": "1", "releaseID": cellxgene_version}
|
|
|
|
server_config = config.server_config
|
|
check = _is_accessible(server_config.single_dataset__datapath, server_config)
|
|
|
|
health["status"] = "pass" if check else "fail"
|
|
code = HTTPStatus.OK if health["status"] == "pass" else HTTPStatus.BAD_REQUEST
|
|
response = make_response(jsonify(health), code)
|
|
response.headers["Content-Type"] = "application/health+json"
|
|
return response
|