1

e11sync-gunicorn is a bit easier to use

This commit is contained in:
2024-01-13 23:07:59 +02:00
parent 4555d5f1f9
commit 96181f5075
2 changed files with 33 additions and 9 deletions

View File

@@ -1,13 +1,29 @@
from pathlib import Path
from os import environ
from os import environ, path
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
_DEBUG = bool(environ.get('E11SYNC_DEBUG', False))
_COMPRESS_OFFLINE = bool(environ.get('E11SYNC_COMPRESS_OFFLINE', False))
_STATIC_ROOT = environ.get('E11SYNC_STATIC_ROOT', '/tmp/e11sync-static')
_GEOIP_PATH = environ.get('GEOIP_PATH')
if db := environ.get('E11SYNC_DATABASE_PATH'):
_DATABASE_PATH = db
else:
if statedir := environ.get('STATE_DIRECTORY'):
_DATABASE_PATH = path.join(statedir, 'db.sqlite3')
else:
_DATABASE_PATH = BASE_DIR / 'db.sqlite3'
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
# otherwise it gets printed twice
if not environ.get("E11SYNC_DEBUG_PRINTED"):
print("DEBUG={}".format(_DEBUG))
print("COMPRESS_OFFLINE={}".format(_COMPRESS_OFFLINE))
print("STATIC_ROOT={}".format(_STATIC_ROOT))
print("GEOIP_PATH={}".format(_GEOIP_PATH))
print("DATABASE_PATH={}".format(_DATABASE_PATH))
environ["E11SYNC_DEBUG_PRINTED"] = "1"
########################################
## No more side effects after this place
@@ -67,7 +83,7 @@ WSGI_APPLICATION = 'e11sync.wsgi.application'
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
'NAME': _DATABASE_PATH,
}
}