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

Add environment variables for Redis and Postgres hosts #1641

Merged
merged 10 commits into from
Jun 5, 2020
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- Throttling policy for unauthenticated users (<https://github.com/opencv/cvat/pull/1531>)
- Added default label color table for mask export (https://github.com/opencv/cvat/pull/1549)
- Added environment variables for Redis and Postgres hosts for Kubernetes deployment support (<https://github.com/opencv/cvat/pull/1641>)
- Added visual identification for unavailable formats (https://github.com/opencv/cvat/pull/1567)

### Changed
Expand Down
8 changes: 4 additions & 4 deletions cvat/settings/production.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
]

for key in RQ_QUEUES:
RQ_QUEUES[key]['HOST'] = 'cvat_redis'
RQ_QUEUES[key]['HOST'] = os.getenv('CVAT_REDIS_HOST', 'cvat_redis')

CACHEOPS_REDIS['host'] = 'cvat_redis'
CACHEOPS_REDIS['host'] = os.getenv('CVAT_REDIS_HOST', 'cvat_redis')

# Django-sendfile:
# https://github.com/johnsensible/django-sendfile
Expand All @@ -25,9 +25,9 @@
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'HOST': 'cvat_db',
'HOST': os.getenv('CVAT_POSTGRES_HOST', 'cvat_db'),
'NAME': 'cvat',
'USER': 'root',
'PASSWORD': os.getenv('POSTGRES_PASSWORD', ''),
'PASSWORD': os.getenv('CVAT_POSTGRES_PASSWORD', ''),
}
}
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ services:
environment:
DJANGO_MODWSGI_EXTRA_ARGS: ""
ALLOWED_HOSTS: '*'
CVAT_REDIS_HOST: "cvat_redis"
CVAT_POSTGRES_HOST: "cvat_db"
volumes:
- cvat_data:/home/django/data
- cvat_keys:/home/django/keys
Expand Down
10 changes: 5 additions & 5 deletions supervisord.conf
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,26 @@ priority=1
autorestart=true

[program:rqworker_default]
command=%(ENV_HOME)s/wait-for-it.sh redis:6379 -t 0 -- bash -ic \
command=%(ENV_HOME)s/wait-for-it.sh %(ENV_CVAT_REDIS_HOST)s:6379 -t 0 -- bash -ic \
"exec /usr/bin/python3 %(ENV_HOME)s/manage.py rqworker -v 3 default"
environment=SSH_AUTH_SOCK="/tmp/ssh-agent.sock"
numprocs=2
process_name=rqworker_default_%(process_num)s

[program:rqworker_low]
command=%(ENV_HOME)s/wait-for-it.sh redis:6379 -t 0 -- bash -ic \
command=%(ENV_HOME)s/wait-for-it.sh %(ENV_CVAT_REDIS_HOST)s:6379 -t 0 -- bash -ic \
"exec /usr/bin/python3 %(ENV_HOME)s/manage.py rqworker -v 3 low"
environment=SSH_AUTH_SOCK="/tmp/ssh-agent.sock"
numprocs=1

[program:git_status_updater]
command=%(ENV_HOME)s/wait-for-it.sh redis:6379 -t 0 -- bash -ic \
command=%(ENV_HOME)s/wait-for-it.sh %(ENV_CVAT_REDIS_HOST)s:6379 -t 0 -- bash -ic \
"/usr/bin/python3 ~/manage.py update_git_states"
environment=SSH_AUTH_SOCK="/tmp/ssh-agent.sock"
numprocs=1

[program:rqscheduler]
command=%(ENV_HOME)s/wait-for-it.sh redis:6379 -t 0 -- bash -ic \
command=%(ENV_HOME)s/wait-for-it.sh %(ENV_CVAT_REDIS_HOST)s:6379 -t 0 -- bash -ic \
"/usr/bin/python3 /usr/local/bin/rqscheduler --host redis -i 30"
environment=SSH_AUTH_SOCK="/tmp/ssh-agent.sock"
numprocs=1
Expand All @@ -53,7 +53,7 @@ numprocs=1
; apps are dynamically loaded by an environment variable. It can lead to issues
; with docker cache. Thus it is necessary to run collectstatic here for such
; apps.
command=%(ENV_HOME)s/wait-for-it.sh db:5432 -t 0 -- bash -ic \
command=%(ENV_HOME)s/wait-for-it.sh %(ENV_CVAT_POSTGRES_HOST)s:5432 -t 0 -- bash -ic \
"rm -f /tmp/cvat-server/httpd.pid && /usr/bin/python3 ~/manage.py migrate && \
/usr/bin/python3 ~/manage.py collectstatic --no-input && \
exec /usr/bin/python3 $HOME/manage.py runmodwsgi --log-to-terminal --port 8080 \
Expand Down