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
40.23k stars 5.51k forks source link

kill signal is not passed to the main process #6158

Closed tmokmss closed 2 weeks ago

tmokmss commented 3 weeks ago

Self Checks

Dify version

0.6.13

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

  1. Run api container bydocker run langgenius/dify-api:0.6.13
  2. Press Ctrl+C or Ctrl+Z

✔️ Expected Behavior

Container is killed by kill signals.

❌ Actual Behavior

Kill signals are ignored and the container is not shut down. Because of this behavior, a container orchestrator such as ECS have to wait for shutdown timeout, slowing down the deployment process. (ref)

dosubot[bot] commented 3 weeks ago

@tmokmss Hello! I'm here to help you with any bugs, questions, or contributions. Feel free to ask for assistance while waiting for a human maintainer.

To ensure that the kill signal is passed to the main process when running Dify version 0.6.13 in a self-hosted Docker environment, you should use the --init flag with the docker run command. This flag runs an init inside the container that forwards signals and reaps processes.

However, since you are using Docker Compose, you can add the init: true option to your docker-compose.yml file for the relevant services. Here is an example of how you can modify your docker-compose.yml file:

version: '3.8'

services:
  api:
    image: langgenius/dify-api:0.6.13
    init: true
    # other configurations

  web:
    image: langgenius/dify-web:0.6.13
    init: true
    # other configurations

  worker:
    image: langgenius/dify-api:0.6.13
    init: true
    # other configurations

  # other services

This ensures that the init system inside the container will handle the forwarding of signals to the main process [1].

To continue talking to Dosu, mention @dosu.