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
|
#!/bin/bash
|
||||||
set -e
|
set -e
|
||||||
|
python manage.py wait_for_db
|
||||||
python manage.py migrate
|
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 -
|
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
|
#!/bin/bash
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
python manage.py wait_for_db
|
||||||
python manage.py migrate
|
python manage.py migrate
|
||||||
|
|
||||||
python manage.py rqworker
|
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():
|
def redis_instance():
|
||||||
if settings.REDIS_URL:
|
if settings.REDIS_URL:
|
||||||
tls_url = os.environ.get("REDIS_TLS_URL", False)
|
ri = redis.from_url(settings.REDIS_URL, db=0)
|
||||||
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,
|
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
ri = redis.StrictRedis(host=settings.REDIS_HOST, port=settings.REDIS_PORT, db=0)
|
ri = redis.StrictRedis(host=settings.REDIS_HOST, port=settings.REDIS_PORT, db=0)
|
||||||
|
|
||||||
|
@ -3,19 +3,24 @@ version: "3.8"
|
|||||||
services:
|
services:
|
||||||
db:
|
db:
|
||||||
image: postgres:12-alpine
|
image: postgres:12-alpine
|
||||||
restart: on-failure
|
restart: always
|
||||||
volumes:
|
volumes:
|
||||||
- postgres-data:/var/lib/postgresql/data
|
- pgdata:/var/lib/postgresql/data
|
||||||
environment:
|
environment:
|
||||||
POSTGRES_USER: plane
|
POSTGRES_USER: plane
|
||||||
POSTGRES_DB: plane
|
POSTGRES_DB: plane
|
||||||
POSTGRES_PASSWORD: plane
|
POSTGRES_PASSWORD: plane
|
||||||
command: postgres -c 'max_connections=1000'
|
command: postgres -c 'max_connections=1000'
|
||||||
|
ports:
|
||||||
|
- "5432:5432"
|
||||||
|
|
||||||
redis:
|
redis:
|
||||||
image: redis:6.2.7-alpine
|
image: redis:6.2.7-alpine
|
||||||
restart: on-failure
|
restart: always
|
||||||
command: redis-server --maxmemory-policy allkeys-lru --maxmemory 200mb
|
ports:
|
||||||
|
- "6379:6379"
|
||||||
|
volumes:
|
||||||
|
- redisdata:/data
|
||||||
|
|
||||||
plane-web:
|
plane-web:
|
||||||
image: plane-web
|
image: plane-web
|
||||||
@ -64,16 +69,20 @@ services:
|
|||||||
- redis
|
- redis
|
||||||
command: ./bin/takeoff
|
command: ./bin/takeoff
|
||||||
links:
|
links:
|
||||||
- db
|
- db:db
|
||||||
- redis
|
- redis:redis
|
||||||
|
|
||||||
plane-worker:
|
plane-worker:
|
||||||
image: plane-api
|
image: plane-api
|
||||||
|
container_name: plane-bg
|
||||||
depends_on:
|
depends_on:
|
||||||
- redis
|
- redis
|
||||||
|
- db
|
||||||
|
- plane-api
|
||||||
command: ./bin/worker
|
command: ./bin/worker
|
||||||
links:
|
links:
|
||||||
- redis
|
- redis:redis
|
||||||
|
- db:db
|
||||||
environment:
|
environment:
|
||||||
SENTRY_DSN: $SENTRY_DSN
|
SENTRY_DSN: $SENTRY_DSN
|
||||||
WEB_URL: $WEB_URL
|
WEB_URL: $WEB_URL
|
||||||
@ -94,4 +103,5 @@ services:
|
|||||||
|
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
postgres-data:
|
pgdata:
|
||||||
|
redisdata:
|
||||||
|
Loading…
Reference in New Issue
Block a user