base container and build process, more django
This commit is contained in:
33
app/tubesync/gunicorn.py
Normal file
33
app/tubesync/gunicorn.py
Normal file
@@ -0,0 +1,33 @@
|
||||
import os
|
||||
import multiprocessing
|
||||
|
||||
|
||||
def get_num_workers():
|
||||
cpu_workers = multiprocessing.cpu_count() * 2 + 1
|
||||
try:
|
||||
num_workers = int(os.getenv('GUNICORN_WORKERS', 1))
|
||||
except ValueError:
|
||||
num_workers = cpu_workers
|
||||
if 0 > num_workers > cpu_workers:
|
||||
num_workers = cpu_workers
|
||||
return num_workers
|
||||
|
||||
|
||||
def get_bind():
|
||||
host = os.getenv('LISTEN_HOST', '0.0.0.0')
|
||||
port = os.getenv('LISTEN_PORT', '8080')
|
||||
return '{}:{}'.format(host, port)
|
||||
|
||||
|
||||
workers = get_num_workers()
|
||||
timeout = 30
|
||||
chdir = '/app'
|
||||
daemon = False
|
||||
pidfile = '/run/www/gunicorn.pid'
|
||||
user = 'www'
|
||||
group = 'www'
|
||||
loglevel = 'info'
|
||||
errorlog = '-'
|
||||
accesslog = '-'
|
||||
django_settings = 'django.settings'
|
||||
bind = get_bind()
|
||||
@@ -0,0 +1,14 @@
|
||||
import os
|
||||
|
||||
|
||||
SECRET_KEY = str(os.getenv('DJANGO_SECRET_KEY', ''))
|
||||
ALLOWED_HOSTS_STR = str(os.getenv('DJANGO_ALLOWED_HOSTS', ''))
|
||||
ALLOWED_HOSTS = ALLOWED_HOSTS_STR.split(',')
|
||||
|
||||
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.sqlite3',
|
||||
'NAME': '/config/db.sqlite3',
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ from pathlib import Path
|
||||
BASE_DIR = Path(__file__).resolve().parent.parent
|
||||
|
||||
|
||||
VERSION = 0.1
|
||||
SECRET_KEY = ''
|
||||
DEBUG = False
|
||||
ALLOWED_HOSTS = []
|
||||
@@ -30,6 +31,8 @@ MIDDLEWARE = [
|
||||
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||||
'django.contrib.messages.middleware.MessageMiddleware',
|
||||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
||||
'whitenoise.middleware.WhiteNoiseMiddleware',
|
||||
'common.middleware.MaterializeDefaultFieldsMiddleware',
|
||||
]
|
||||
|
||||
|
||||
@@ -47,6 +50,7 @@ TEMPLATES = [
|
||||
'django.template.context_processors.request',
|
||||
'django.contrib.auth.context_processors.auth',
|
||||
'django.contrib.messages.context_processors.messages',
|
||||
'common.context_processors.app_details',
|
||||
],
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user