feat(docker): Add worker service config for SupervisorD

ref: #363 #371
This commit is contained in:
2024-10-31 15:00:55 +09:30
parent 4303232543
commit 8479130ef1
4 changed files with 35 additions and 1 deletions

View File

@ -100,6 +100,8 @@ ENV CI_PROJECT_URL=${CI_PROJECT_URL}
ENV CI_COMMIT_SHA=${CI_COMMIT_SHA}
ENV CI_COMMIT_TAG=${CI_COMMIT_TAG}
ENV IS_WORKER=False
COPY requirements.txt requirements.txt
COPY requirements_test.txt requirements_test.txt

View File

@ -50,7 +50,7 @@ The [web container](https://hub.docker.com/r/nofusscomputing/centurion-erp) is t
### Background Worker Container
The [Background Worker container](https://hub.docker.com/r/nofusscomputing/centurion-erp) is a worker that waits for tasks sent to the RabbitMQ server. The worker is based upon [Celery](https://docs.celeryq.dev/en/stable/index.html). On the worker not being busy, it'll pickup and run the task. This container is scalable with nil additional requirements for launching additional workers. If deploying to Kubernetes the setting the deployment `replicas` to the number of desired containers is the simplest method to scale. The container start command will need to be set to `celery -A app worker -l INFO` so that the worker is started on container startup.
The [Background Worker container](https://hub.docker.com/r/nofusscomputing/centurion-erp) is a worker that waits for tasks sent to the RabbitMQ server. The worker is based upon [Celery](https://docs.celeryq.dev/en/stable/index.html). On the worker not being busy, it'll pickup and run the task. This container is scalable with nil additional requirements for launching additional workers. If deploying to Kubernetes the setting the deployment `replicas` to the number of desired containers is the simplest method to scale. There is no container start command, however you will need to set environmental variable `IS_WORKER` to value `'True'` within the container.
Configuration for the worker resides in directory `/etc/itsm/` within the container. see below for the `CELERY_` configuration.

View File

@ -7,6 +7,25 @@ if [ "$1" == "" ]; then
echo "[Info] Setup SupervisorD"
if [ ${IS_WORKER} == 'True' ] || [ ${IS_WORKER} == 'true' ]; then
echo '[info] Creating worker service config';
cp /etc/supervisor/conf.source/worker.conf /etc/supervisor/conf.d/worker.conf;
if [ -f '/etc/supervisor/conf.d/worker.conf' ]; then
echo '[info] Worker service config Created';
else
echo '[crit] Worker service config not created';
fi;
else
echo '[info] Creating gunicorn service config';
@ -38,6 +57,9 @@ if [ "$1" == "" ]; then
fi;
fi;
echo "[Info] SupervisorD Setup successfully"

View File

@ -0,0 +1,10 @@
[program:celery]
priority=1
startsecs=0
stopwaitsecs=55
autostart=true
autorestart=true
stdout_logfile=/var/log/%(program_name)s.log
stderr_logfile=/var/log/%(program_name)s.log
directory=/app
command=celery -A app worker -l INFO