Skip to content

Commit

Permalink
celery flower service added
Browse files Browse the repository at this point in the history
  • Loading branch information
deepakdinesh1123 committed Aug 30, 2024
1 parent 8e08316 commit 7bbf449
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 1 deletion.
1 change: 1 addition & 0 deletions backend/requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,4 @@ python3-saml==1.16.0
pytz==2024.1
setuptools==70.1.1
XlsxWriter==3.1.9
flower==2.0.1
1 change: 1 addition & 0 deletions deploy/dev.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@ USER zango_user


COPY init.sh /zango/
COPY start_flower.sh /zango/
WORKDIR /zango/
CMD ["/bin/sh", "init.sh"]
24 changes: 23 additions & 1 deletion deploy/docker_compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,29 @@ services:
redis:
condition: service_healthy

celery-flower:
build:
context: .
dockerfile: dev.dockerfile
args:
- HOST_UID=${HOST_UID}
- HOST_GID=${HOST_GID}
restart: always
entrypoint:
- /bin/sh
- start_flower.sh
ports:
- "5555:5555"
env_file:
- .env
volumes:
- .:/zango/
depends_on:
- postgres
- redis
- celery
- celery_beat

redis:
image: redis
ports:
Expand All @@ -83,6 +106,5 @@ services:
redis:
condition: service_healthy


volumes:
dev_db:
22 changes: 22 additions & 0 deletions deploy/docker_compose.prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,28 @@ services:
timeout: 5s
retries: 3

celery-flower:
build:
context: .
dockerfile: prod.dockerfile
args:
- HOST_UID=${HOST_UID}
- HOST_GID=${HOST_GID}
restart: always
entrypoint:
- /bin/sh
- start_flower.sh
ports:
- "5555:5555"
env_file:
- .env
volumes:
- .:/zango/
depends_on:
- postgres
- redis
- celery

celery_beat:
image: kczelthy/zango:latest
command: /bin/sh -c "cd ${PROJECT_NAME} && celery -A ${PROJECT_NAME} beat -l info --scheduler django_celery_beat.schedulers:DatabaseScheduler"
Expand Down
1 change: 1 addition & 0 deletions deploy/prod.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@ RUN apt update && \
USER zango_user

COPY init.sh /zango/
COPY start_flower.sh /zango/
WORKDIR /zango/
CMD ["/bin/sh", "init.sh"]
9 changes: 9 additions & 0 deletions deploy/start_flower.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh

cd ${PROJECT_NAME}
until timeout 5s celery -A ${PROJECT_NAME} inspect ping; do
>&2 echo "Celery workers not available"
done

echo 'Starting flower'
celery -A ${PROJECT_NAME} flower --port=5555 --broker=redis://redis:6379/0
1 change: 1 addition & 0 deletions setup_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def load_necessary_files(project_dir, project_name, without_db):
shutil.copy("deploy/dev.dockerfile", f"{project_dir}/dev.dockerfile")
shutil.copy("deploy/prod.dockerfile", f"{project_dir}/prod.dockerfile")
shutil.copy("deploy/init.sh", f"{project_dir}/init.sh")
shutil.copy("deploy/start_flower.sh", f"{project_dir}/start_flower.sh")


def write_env_file(project_dir, args):
Expand Down

0 comments on commit 7bbf449

Please sign in to comment.