From 1d25cf2034bcc2769013f6be3c389e027cbd8cac Mon Sep 17 00:00:00 2001 From: duncte123 Date: Tue, 12 Mar 2024 15:05:56 +0100 Subject: [PATCH] Runs but no WS --- Dockerfile | 10 ++++++---- asgi.py | 16 ++++++++++++++++ entrypoint.sh | 3 ++- manage.py | 2 +- settings.py | 25 +++++++++---------------- tracker | 2 +- wsgi.py | 19 ++++++++++++------- 7 files changed, 47 insertions(+), 30 deletions(-) create mode 100644 asgi.py diff --git a/Dockerfile b/Dockerfile index 491a798..4770103 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,7 +18,7 @@ COPY ./tracker/tracker tracker RUN yarn build -FROM python:3.11 +FROM python:3.12 WORKDIR /app @@ -35,16 +35,18 @@ COPY \ ./tracker/setup.py \ ./ -COPY ./tracker/tracker tracker COPY --from=client /app/tracker/ tracker +COPY ./tracker/tracker tracker RUN pip install -e . -#RUN pip install gunicorn +RUN pip install 'uvicorn[daphne]' gunicorn WORKDIR /app/tracker_development -COPY ./settings.py ./local_statics.py ./routing.py ./urls.py /app/tracker_development/tracker_development/ +COPY ./settings.py ./wsgi.py ./asgi.py ./local_statics.py ./routing.py ./urls.py /app/tracker_development/tracker_development/ COPY ./entrypoint.sh ./ RUN mkdir db +#RUN pip install ./donation-tracker + RUN apt update RUN apt install -y locales #RUN echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen diff --git a/asgi.py b/asgi.py new file mode 100644 index 0000000..4b95a4f --- /dev/null +++ b/asgi.py @@ -0,0 +1,16 @@ +""" +ASGI config for tracker_development project. + +It exposes the ASGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/3.2/howto/deployment/asgi/ +""" + +import os + +from django.core.asgi import get_asgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'tracker_development.settings') + +application = get_asgi_application() diff --git a/entrypoint.sh b/entrypoint.sh index b4e510e..659c1f6 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -24,7 +24,8 @@ rm -rf /var/ww/html/static/gen || true python manage.py collectstatic --noinput if [ -x "$(command -v gunicorn)" ]; then - gunicorn --bind 0.0.0.0:8000 tracker_development.wsgi +# gunicorn --bind 0.0.0.0:8000 tracker_development.wsgi + python -m gunicorn --bind 0.0.0.0:8000 tracker_development.asgi:application -k uvicorn.workers.UvicornWorker else echo "Gunicorn not installed: Using built-in server." # watchmedo shell-command --patterns="*.css" -R -c "python manage.py collectstatic --noinput" & diff --git a/manage.py b/manage.py index 1b243ab..2ce69d9 100755 --- a/manage.py +++ b/manage.py @@ -6,7 +6,7 @@ def main(): """Run administrative tasks.""" - os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'settings') + os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'tracker_development.settings') try: from django.core.management import execute_from_command_line except ImportError as exc: diff --git a/settings.py b/settings.py index c05be8b..3a77c9d 100755 --- a/settings.py +++ b/settings.py @@ -5,9 +5,11 @@ try: import tracker_development.local as local + print('Loaded normal settings') except ImportError: try: import tracker_development.local_statics as local + print('Loaded statics settings') except ImportError: import tracker_development.example_local as local @@ -82,15 +84,6 @@ # to load the internationalization machinery. USE_I18N = True -gettext = lambda x: x -LANGUAGES = ( -# ('de',gettext('German')), - ('en',gettext('English')), -# ('ja',gettext('Japanese')), -# ('nl',gettext('Dutch')), -# ('pl',gettext('Polish')), -) - # If you set this to False, Django will not format dates, numbers and # calendars according to the current locale. USE_L10N = True @@ -124,19 +117,19 @@ # List of finder classes that know how to find static files in # various locations. -STATICFILES_FINDERS = ( +STATICFILES_FINDERS = [ 'django.contrib.staticfiles.finders.FileSystemFinder', 'django.contrib.staticfiles.finders.AppDirectoriesFinder', -) +] # Make this unique, and don't share it with anybody. SECRET_KEY = local.SECRET_KEY # List of callables that know how to import templates from various sources. -TEMPLATE_LOADERS = ( +TEMPLATE_LOADERS = [ 'django.template.loaders.filesystem.Loader', 'django.template.loaders.app_directories.Loader', -) +] MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', @@ -172,7 +165,7 @@ }, ] -INSTALLED_APPS = ( +INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', @@ -187,7 +180,7 @@ 'timezone_field', 'ajax_select', 'mptt', -) +] EMAIL_BACKEND = local.EMAIL_BACKEND @@ -197,7 +190,7 @@ # Pull in the tracker's lookup channels from tracker import ajax_lookup_channels AJAX_LOOKUP_CHANNELS = ajax_lookup_channels.AJAX_LOOKUP_CHANNELS -ASGI_APPLICATION = 'routing.application' +ASGI_APPLICATION = 'tracker_development.routing.application' CHANNEL_LAYERS = {'default': {'BACKEND': 'channels.layers.InMemoryChannelLayer'}} # AUTHENTICATION_BACKENDS = ( diff --git a/tracker b/tracker index a145bc9..62fce4f 160000 --- a/tracker +++ b/tracker @@ -1 +1 @@ -Subproject commit a145bc93e0dbe0e7a883aa24301a4f9dbe72a938 +Subproject commit 62fce4ff1a6ce0aa983fae9035bfcf4b20e4f5d0 diff --git a/wsgi.py b/wsgi.py index 50f49cc..ac807b1 100755 --- a/wsgi.py +++ b/wsgi.py @@ -1,16 +1,21 @@ +""" +WSGI config for tracker_development project. + +It exposes the WSGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/3.2/howto/deployment/wsgi/ +""" + import os import sys import logging import inspect -# I put it ahead so that it will take the local paypal app over the global one -os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'settings') -os.environ.setdefault("LC_ALL", "en_US.utf8") - -# This application object is used by any WSGI server configured to use this -# file. This includes Django's development server, if the WSGI_APPLICATION -# setting points here. from django.core.wsgi import get_wsgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'tracker_development.settings') + application = get_wsgi_application() logger = logging.getLogger('')