您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

system_app.py 2.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #
  2. # Copyright 2024 The InfiniFlow Authors. All Rights Reserved.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License
  15. #
  16. from flask_login import login_required
  17. from api.db.services.knowledgebase_service import KnowledgebaseService
  18. from api.utils.api_utils import get_json_result
  19. from api.versions import get_rag_version
  20. from rag.settings import SVR_QUEUE_NAME
  21. from rag.utils.es_conn import ELASTICSEARCH
  22. from rag.utils.minio_conn import MINIO
  23. from timeit import default_timer as timer
  24. from rag.utils.redis_conn import REDIS_CONN
  25. @manager.route('/version', methods=['GET'])
  26. @login_required
  27. def version():
  28. return get_json_result(data=get_rag_version())
  29. @manager.route('/status', methods=['GET'])
  30. @login_required
  31. def status():
  32. res = {}
  33. st = timer()
  34. try:
  35. res["es"] = ELASTICSEARCH.health()
  36. res["es"]["elapsed"] = "{:.1f}".format((timer() - st)*1000.)
  37. except Exception as e:
  38. res["es"] = {"status": "red", "elapsed": "{:.1f}".format((timer() - st)*1000.), "error": str(e)}
  39. st = timer()
  40. try:
  41. MINIO.health()
  42. res["minio"] = {"status": "green", "elapsed": "{:.1f}".format((timer() - st)*1000.)}
  43. except Exception as e:
  44. res["minio"] = {"status": "red", "elapsed": "{:.1f}".format((timer() - st)*1000.), "error": str(e)}
  45. st = timer()
  46. try:
  47. KnowledgebaseService.get_by_id("x")
  48. res["mysql"] = {"status": "green", "elapsed": "{:.1f}".format((timer() - st)*1000.)}
  49. except Exception as e:
  50. res["mysql"] = {"status": "red", "elapsed": "{:.1f}".format((timer() - st)*1000.), "error": str(e)}
  51. st = timer()
  52. try:
  53. if not REDIS_CONN.health():
  54. raise Exception("Lost connection!")
  55. res["redis"] = {"status": "green", "elapsed": "{:.1f}".format((timer() - st)*1000.)}
  56. except Exception as e:
  57. res["redis"] = {"status": "red", "elapsed": "{:.1f}".format((timer() - st)*1000.), "error": str(e)}
  58. return get_json_result(data=res)