langgenius / dify

Dify is an open-source LLM app development platform. Dify's intuitive interface combines AI workflow, RAG pipeline, agent capabilities, model management, observability features and more, letting you quickly go from prototype to production.
https://dify.ai
Other
49.48k stars 7.08k forks source link

error in api and worker #8213

Closed damadorPL closed 1 month ago

damadorPL commented 1 month ago

Self Checks

Dify version

0.8.0

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

simply docker compose up -d from gothub

api log

Running migrations Traceback (most recent call last): File "/app/api/.venv/bin/flask", line 8, in <module> sys.exit(main()) File "/app/api/.venv/lib/python3.10/site-packages/flask/cli.py", line 1105, in main cli.main() File "/app/api/.venv/lib/python3.10/site-packages/click/core.py", line 1078, in main rv = self.invoke(ctx) File "/app/api/.venv/lib/python3.10/site-packages/click/core.py", line 1682, in invoke cmd_name, cmd, args = self.resolve_command(ctx, args) File "/app/api/.venv/lib/python3.10/site-packages/click/core.py", line 1729, in resolve_command cmd = self.get_command(ctx, cmd_name) File "/app/api/.venv/lib/python3.10/site-packages/flask/cli.py", line 611, in get_command app = info.load_app() File "/app/api/.venv/lib/python3.10/site-packages/flask/cli.py", line 335, in load_app app = locate_app(import_name, name) File "/app/api/.venv/lib/python3.10/site-packages/flask/cli.py", line 245, in locate_app __import__(module_name) File "/app/api/app.py", line 24, in <module> import contexts File "/app/api/contexts/__init__.py", line 3, in <module> from core.workflow.entities.variable_pool import VariablePool File "/app/api/core/__init__.py", line 1, in <module> import core.moderation.base File "/app/api/core/moderation/base.py", line 7, in <module> from core.extension.extensible import Extensible, ExtensionModule File "/app/api/core/extension/extensible.py", line 10, in <module> from core.helper.position_helper import sort_to_dict_by_position_map File "/app/api/core/helper/position_helper.py", line 6, in <module> from configs import dify_config File "/app/api/configs/__init__.py", line 3, in <module> dify_config = DifyConfig() File "/app/api/.venv/lib/python3.10/site-packages/pydantic_settings/main.py", line 144, in __init__ super().__init__( File "/app/api/.venv/lib/python3.10/site-packages/pydantic/main.py", line 193, in __init__ self.__pydantic_validator__.validate_python(data, self_instance=self) pydantic_core._pydantic_core.ValidationError: 2 validation errors for DifyConfig REDIS_SENTINEL_SOCKET_TIMEOUT Input should be a valid number, unable to parse string as a number [type=float_parsing, input_value='', input_type=str] For further information visit https://errors.pydantic.dev/2.8/v/float_parsing CELERY_SENTINEL_SOCKET_TIMEOUT Input should be a valid number, unable to parse string as a number [type=float_parsing, input_value='', input_type=str]

worker log

Running migrations Traceback (most recent call last): File "/app/api/.venv/bin/flask", line 8, in <module> sys.exit(main()) File "/app/api/.venv/lib/python3.10/site-packages/flask/cli.py", line 1105, in main cli.main() File "/app/api/.venv/lib/python3.10/site-packages/click/core.py", line 1078, in main rv = self.invoke(ctx) File "/app/api/.venv/lib/python3.10/site-packages/click/core.py", line 1682, in invoke cmd_name, cmd, args = self.resolve_command(ctx, args) File "/app/api/.venv/lib/python3.10/site-packages/click/core.py", line 1729, in resolve_command cmd = self.get_command(ctx, cmd_name) File "/app/api/.venv/lib/python3.10/site-packages/flask/cli.py", line 611, in get_command app = info.load_app() File "/app/api/.venv/lib/python3.10/site-packages/flask/cli.py", line 335, in load_app app = locate_app(import_name, name) File "/app/api/.venv/lib/python3.10/site-packages/flask/cli.py", line 245, in locate_app __import__(module_name) File "/app/api/app.py", line 24, in <module> import contexts File "/app/api/contexts/__init__.py", line 3, in <module> from core.workflow.entities.variable_pool import VariablePool File "/app/api/core/__init__.py", line 1, in <module> import core.moderation.base File "/app/api/core/moderation/base.py", line 7, in <module> from core.extension.extensible import Extensible, ExtensionModule File "/app/api/core/extension/extensible.py", line 10, in <module> from core.helper.position_helper import sort_to_dict_by_position_map File "/app/api/core/helper/position_helper.py", line 6, in <module> from configs import dify_config File "/app/api/configs/__init__.py", line 3, in <module> dify_config = DifyConfig() File "/app/api/.venv/lib/python3.10/site-packages/pydantic_settings/main.py", line 144, in __init__ super().__init__( File "/app/api/.venv/lib/python3.10/site-packages/pydantic/main.py", line 193, in __init__ self.__pydantic_validator__.validate_python(data, self_instance=self) pydantic_core._pydantic_core.ValidationError: 2 validation errors for DifyConfig REDIS_SENTINEL_SOCKET_TIMEOUT Input should be a valid number, unable to parse string as a number [type=float_parsing, input_value='', input_type=str] For further information visit https://errors.pydantic.dev/2.8/v/float_parsing CELERY_SENTINEL_SOCKET_TIMEOUT Input should be a valid number, unable to parse string as a number [type=float_parsing, input_value='', input_type=str] For further information visit https://errors.pydantic.dev/2.8/v/float_parsing

redis log - this one works

1:C 10 Sep 2024 09:21:03.521 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo 1:C 10 Sep 2024 09:21:03.521 # Redis version=6.2.14, bits=64, commit=00000000, modified=0, pid=1, just started 1:C 10 Sep 2024 09:21:03.521 # Configuration loaded 1:M 10 Sep 2024 09:21:03.522 * monotonic clock: POSIX clock_gettime 1:M 10 Sep 2024 09:21:03.523 * Running mode=standalone, port=6379. 1:M 10 Sep 2024 09:21:03.523 # Server initialized 1:M 10 Sep 2024 09:21:03.523 # WARNING Memory overcommit must be enabled! Without it, a background save or replication may fail under low memory condition. Being disabled, it can can also cause failures without low memory condition, see https://github.com/jemalloc/jemalloc/issues/1328. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect. 1:M 10 Sep 2024 09:21:03.524 * Loading RDB produced by version 6.2.14 1:M 10 Sep 2024 09:21:03.524 * RDB age 11 seconds 1:M 10 Sep 2024 09:21:03.524 * RDB memory usage when created 0.78 Mb 1:M 10 Sep 2024 09:21:03.524 # Done loading RDB, keys loaded: 10, keys expired: 0. 1:M 10 Sep 2024 09:21:03.524 * DB loaded from disk: 0.000 seconds 1:M 10 Sep 2024 09:21:03.524 * Ready to accept connections

✔️ Expected Behavior

api should work

❌ Actual Behavior

api not work

dosubot[bot] commented 1 month ago

Hello, @damadorPL! I'm here to help you with any bugs or questions you have while waiting for a human maintainer. Let's tackle this together!

To resolve the ValidationError in DifyConfig related to REDIS_SENTINEL_SOCKET_TIMEOUT and CELERY_SENTINEL_SOCKET_TIMEOUT when running the API and worker in Docker, you need to ensure that these environment variables are set with appropriate values.

In your docker-compose.yaml, you can set these variables under the x-shared-env section:

x-shared-env: &shared-api-worker-env
  ...
  REDIS_SENTINEL_SOCKET_TIMEOUT: ${REDIS_SENTINEL_SOCKET_TIMEOUT:-0.1}
  CELERY_SENTINEL_SOCKET_TIMEOUT: ${CELERY_SENTINEL_SOCKET_TIMEOUT:-0.1}
  ...

Make sure to replace 0.1 with the appropriate timeout value in seconds that you want to use. This will ensure that both REDIS_SENTINEL_SOCKET_TIMEOUT and CELERY_SENTINEL_SOCKET_TIMEOUT are set correctly and should resolve the ValidationError.

Additionally, you can refer to the .env.example file provided by Dify for more context on these environment variables:

# ------------------------------
# Redis Configuration
# ------------------------------
REDIS_SENTINEL_SOCKET_TIMEOUT=0.1

# ------------------------------
# Celery Configuration
# ------------------------------
CELERY_SENTINEL_SOCKET_TIMEOUT=0.1

According to the Dify documentation, the default value for REDIS_SENTINEL_SOCKET_TIMEOUT and CELERY_SENTINEL_SOCKET_TIMEOUT is 0.1 seconds [1][2][3].

To continue talking to Dosu, mention @dosu.

crazywoola commented 1 month ago

Try the bot's solution.

damadorPL commented 1 month ago

changed 0.1 to 10 fixed issue