You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

runtime_config.py 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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 api.versions import get_ragflow_version
  17. from .reload_config_base import ReloadConfigBase
  18. class RuntimeConfig(ReloadConfigBase):
  19. DEBUG = None
  20. WORK_MODE = None
  21. HTTP_PORT = None
  22. JOB_SERVER_HOST = None
  23. JOB_SERVER_VIP = None
  24. ENV = dict()
  25. SERVICE_DB = None
  26. LOAD_CONFIG_MANAGER = False
  27. @classmethod
  28. def init_config(cls, **kwargs):
  29. for k, v in kwargs.items():
  30. if hasattr(cls, k):
  31. setattr(cls, k, v)
  32. @classmethod
  33. def init_env(cls):
  34. cls.ENV.update({"version": get_ragflow_version()})
  35. @classmethod
  36. def load_config_manager(cls):
  37. cls.LOAD_CONFIG_MANAGER = True
  38. @classmethod
  39. def get_env(cls, key):
  40. return cls.ENV.get(key, None)
  41. @classmethod
  42. def get_all_env(cls):
  43. return cls.ENV
  44. @classmethod
  45. def set_service_db(cls, service_db):
  46. cls.SERVICE_DB = service_db