Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat(command): Gracefully stopping the workerΒ #295

@Guikingone

Description

@Guikingone

Situation

Currently I'm using scheduler as separate service in my docker compose setup. All my scheduled tasks are send to the message queue. Consuming the messages is also done in a separate service.

# docker-compose.yml
version: '3.9'

services:
  phpfpm:
    extends:
      file: common-services.yml
      service: php-base
    restart: always

  messenger:
    extends:
      file: common-services.yml
      service: php-base
    depends_on:
      - rabbitmq
    restart: 'no'
    command: bin/console messenger:consume -vv async

  schedule:
    extends:
      file: common-services.yml
      service: php-base
    depends_on:
      - rabbitmq
    restart: 'no'
    command: bin/console scheduler:consume --wait --force -vv

Messenger has a command called messenger:stop-workers, which will gracefully stop workers by completing the currently handled messages and then stops further consuming. This is nice as I can send this command to the messenger container, poll the status of the container for status exited, and know it has completely stopped (and continue with deployment) without the actual need of stopping the container using docker compose stop.

Now for the schedule service, I'm running the consume command with --wait --force, which keeps the container alive and waits for new tasks to be handled (similar kind of behavior as the messenger service). Currently, as there is no native command for scheduler to stop (like at messenger), I am forced to stop the container directly.

Question

Thinking about the above, I got the following questions:

Originally posted by @ToshY in #294

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions