Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix celery beat terminal filling startup and operational 5 second logs #146

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
"""This is a helper script meant for celery beat to check for migrations. The beat
error log is too large and hides from your terminal the most common case in which you
will have issues with the migrations or around the same time migrations are running."""

import time
from django.db import ProgrammingError
import nautobot

nautobot.setup()

from nautobot.extras.models.jobs import ScheduledJob

while True:
try:
list(ScheduledJob.objects.all())
print("Migrations are complete, proceeding.")
break
except ProgrammingError:
print("Migrations not complete yet, retrying in 5 seconds...")
time.sleep(5) # Wait for a few seconds before retrying
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,13 @@ services:
entrypoint:
- "sh"
- "-c" # this is to evaluate the $NAUTOBOT_LOG_LEVEL from the env
- "watchmedo auto-restart --directory './' --pattern '*.py' --recursive -- nautobot-server celery beat -l $$NAUTOBOT_LOG_LEVEL" ## $$ because of docker-compose
- |
python /opt/nautobot/check_migrations.py && \
"watchmedo auto-restart --directory './' --pattern '*.py' --recursive -- nautobot-server celery beat -l WARNING"
volumes:
- "./nautobot_config.py:/opt/nautobot/nautobot_config.py"
- "../:/source"
- "./check_migrations.py:/opt/nautobot/check_migrations.py"
# To expose postgres or redis to the host uncomment the following
# postgres:
# ports:
Expand Down
Loading