Skip to content

Commit

Permalink
build: run huey consumer as a runit deamon in the server service
Browse files Browse the repository at this point in the history
this is considerably easier to manage than creating a clone service, not
sure if there is any potential downside to not isolating the two
processes
  • Loading branch information
sgfost committed Sep 11, 2024
1 parent 2be1b90 commit 4be9693
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 39 deletions.
26 changes: 0 additions & 26 deletions base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,32 +85,6 @@ services:
condition: service_started
env_file:
- ./.env
huey:
build: django
image: comses/huey
secrets:
- db_password
- discourse_api_key
- discourse_sso_secret
- django_secret_key
- github_client_secret
- orcid_client_secret
- github_app_private_key
- github_app_client_secret
- hcaptcha_secret
- mail_api_key
volumes:
- ./deploy/elasticsearch.conf.d:/etc/elasticsearch
- ./docker/shared:/shared
- ./.env:/etc/environment
command: ["/code/manage.py", "run_huey"]
depends_on:
server:
condition: service_started
redis:
condition: service_started
env_file:
- ./.env

secrets:
db_password:
Expand Down
9 changes: 0 additions & 9 deletions dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,3 @@ services:
DJANGO_SETTINGS_MODULE: "core.settings.dev"
ports:
- "127.0.0.1:8000:8000"
huey:
build:
args:
UBUNTU_MIRROR: "${UBUNTU_MIRROR}"
image: comses/huey:dev
volumes:
- ./django:/code
environment:
DJANGO_SETTINGS_MODULE: "core.settings.dev"
7 changes: 4 additions & 3 deletions django/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ RUN --mount=type=cache,target=/var/lib/apt,sharing=locked \
unzip \
&& update-alternatives --install /usr/bin/python python /usr/bin/python3 1000 \
&& apt-get upgrade -y -o Dpkg::Options::="--force-confold" \
&& mkdir -p /etc/service/django \
&& touch /etc/service/django/run /etc/postgresql-backup-pre \
&& chmod a+x /etc/service/django/run /etc/postgresql-backup-pre \
&& mkdir -p /etc/service/django /etc/service/huey \
&& touch /etc/service/django/run /etc/service/huey/run /etc/postgresql-backup-pre \
&& chmod a+x /etc/service/django/run /etc/service/huey/run /etc/postgresql-backup-pre \
&& apt-get autoremove -y && apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

WORKDIR /code
Expand All @@ -58,5 +58,6 @@ COPY ./deploy/cron.weekly/* /etc/cron.weekly/
COPY ./deploy/db/autopostgresqlbackup.conf /etc/default/autopostgresqlbackup
COPY ./deploy/db/postgresql-backup-pre /etc/
COPY ${RUN_SCRIPT} /etc/service/django/run
COPY ./deploy/huey.sh /etc/service/huey/run
COPY . /code
CMD ["/sbin/my_init"]
3 changes: 2 additions & 1 deletion django/core/settings/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ def is_test(self):
"level": "INFO",
"handlers": ["console", "comsesfile"],
"propagate": False,
}, # FIXME: change this in prod
},
},
}

Expand Down Expand Up @@ -485,6 +485,7 @@ def is_test(self):
"name": "comses",
"huey_class": "core.huey.DjangoRedisHuey",
"immediate": False, # always run tasks in the background, even in dev (for now)
# if removed here, it will default to DEBUG
}

# SSO, user registration, and django-allauth configuration, see
Expand Down
5 changes: 5 additions & 0 deletions django/core/settings/staging.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,5 +177,10 @@
"handlers": ["comsesfile"],
"propagate": False,
},
"huey": {
"level": "WARNING",
"handlers": ["comsesfile"],
"propagate": False,
},
},
}
2 changes: 2 additions & 0 deletions django/deploy/huey.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
exec /code/manage.py run_huey

0 comments on commit 4be9693

Please sign in to comment.