forked from github/plane
build: updated config for redis and wait_for_db command
This commit is contained in:
parent
db10c884e8
commit
4414a71331
@ -1,5 +1,5 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
python manage.py wait_for_db
|
||||
python manage.py migrate
|
||||
exec gunicorn plane.wsgi -k gthread --workers 8 --bind 0.0.0.0:8000 --config gunicorn.config.py --max-requests 10000 --max-requests-jitter 1000 --access-logfile -
|
||||
|
@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
python manage.py wait_for_db
|
||||
python manage.py migrate
|
||||
|
||||
python manage.py rqworker
|
0
apiserver/plane/db/management/__init__.py
Normal file
0
apiserver/plane/db/management/__init__.py
Normal file
0
apiserver/plane/db/management/commands/__init__.py
Normal file
0
apiserver/plane/db/management/commands/__init__.py
Normal file
19
apiserver/plane/db/management/commands/wait_for_db.py
Normal file
19
apiserver/plane/db/management/commands/wait_for_db.py
Normal file
@ -0,0 +1,19 @@
|
||||
import time
|
||||
from django.db import connections
|
||||
from django.db.utils import OperationalError
|
||||
from django.core.management import BaseCommand
|
||||
|
||||
class Command(BaseCommand):
|
||||
"""Django command to pause execution until db is available"""
|
||||
|
||||
def handle(self, *args, **options):
|
||||
self.stdout.write('Waiting for database...')
|
||||
db_conn = None
|
||||
while not db_conn:
|
||||
try:
|
||||
db_conn = connections['default']
|
||||
except OperationalError:
|
||||
self.stdout.write('Database unavailable, waititng 1 second...')
|
||||
time.sleep(1)
|
||||
|
||||
self.stdout.write(self.style.SUCCESS('Database available!'))
|
@ -6,17 +6,7 @@ from urllib.parse import urlparse
|
||||
|
||||
def redis_instance():
|
||||
if settings.REDIS_URL:
|
||||
tls_url = os.environ.get("REDIS_TLS_URL", False)
|
||||
url = urlparse(settings.REDIS_URL)
|
||||
if tls_url:
|
||||
url = urlparse(tls_url)
|
||||
ri = redis.Redis(
|
||||
host=url.hostname,
|
||||
port=url.port,
|
||||
password=url.password,
|
||||
ssl=True,
|
||||
ssl_cert_reqs=None,
|
||||
)
|
||||
ri = redis.from_url(settings.REDIS_URL, db=0)
|
||||
else:
|
||||
ri = redis.StrictRedis(host=settings.REDIS_HOST, port=settings.REDIS_PORT, db=0)
|
||||
|
||||
|
@ -3,19 +3,24 @@ version: "3.8"
|
||||
services:
|
||||
db:
|
||||
image: postgres:12-alpine
|
||||
restart: on-failure
|
||||
restart: always
|
||||
volumes:
|
||||
- postgres-data:/var/lib/postgresql/data
|
||||
- pgdata:/var/lib/postgresql/data
|
||||
environment:
|
||||
POSTGRES_USER: plane
|
||||
POSTGRES_DB: plane
|
||||
POSTGRES_PASSWORD: plane
|
||||
command: postgres -c 'max_connections=1000'
|
||||
ports:
|
||||
- "5432:5432"
|
||||
|
||||
redis:
|
||||
image: redis:6.2.7-alpine
|
||||
restart: on-failure
|
||||
command: redis-server --maxmemory-policy allkeys-lru --maxmemory 200mb
|
||||
restart: always
|
||||
ports:
|
||||
- "6379:6379"
|
||||
volumes:
|
||||
- redisdata:/data
|
||||
|
||||
plane-web:
|
||||
image: plane-web
|
||||
@ -64,16 +69,20 @@ services:
|
||||
- redis
|
||||
command: ./bin/takeoff
|
||||
links:
|
||||
- db
|
||||
- redis
|
||||
- db:db
|
||||
- redis:redis
|
||||
|
||||
plane-worker:
|
||||
image: plane-api
|
||||
container_name: plane-bg
|
||||
depends_on:
|
||||
- redis
|
||||
- db
|
||||
- plane-api
|
||||
command: ./bin/worker
|
||||
links:
|
||||
- redis
|
||||
- redis:redis
|
||||
- db:db
|
||||
environment:
|
||||
SENTRY_DSN: $SENTRY_DSN
|
||||
WEB_URL: $WEB_URL
|
||||
@ -94,4 +103,5 @@ services:
|
||||
|
||||
|
||||
volumes:
|
||||
postgres-data:
|
||||
pgdata:
|
||||
redisdata:
|
||||
|
Loading…
Reference in New Issue
Block a user