From 39173b5c7b86564524780b99140fbccf49dcb2c7 Mon Sep 17 00:00:00 2001 From: Guillaume Pellerin Date: Wed, 13 Apr 2016 13:47:37 +0200 Subject: [PATCH] refactor app --- .gitignore | 1 + app/deploy/nginx-dev.conf | 28 ----------------------- app/manage.py | 4 +--- app/{sandbox => }/robots.txt | 0 app/sandbox/__init__.py | 1 - app/{deploy => scripts}/app.sh | 6 ++--- app/{sandbox => scripts}/diag.sh | 0 app/{sandbox => scripts}/modelviz.py | 0 app/{sandbox => scripts}/update_schema.sh | 0 app/{deploy => scripts}/wait.sh | 4 ++-- app/{deploy => scripts}/worker.sh | 2 +- app/{sandbox => }/settings.py | 2 +- app/{sandbox => }/urls.py | 0 app/worker.py | 5 ++-- app/wsgi.py | 4 ++-- docker-compose.yml | 6 ++--- env/build.yml | 28 ----------------------- env/debug.yml | 3 --- env/dev.yml | 2 +- {app/deploy => etc}/apt.list | 0 {app/deploy => etc}/nginx.conf | 0 21 files changed, 18 insertions(+), 78 deletions(-) delete mode 100644 app/deploy/nginx-dev.conf rename app/{sandbox => }/robots.txt (100%) delete mode 100644 app/sandbox/__init__.py rename app/{deploy => scripts}/app.sh (93%) rename app/{sandbox => scripts}/diag.sh (100%) rename app/{sandbox => scripts}/modelviz.py (100%) rename app/{sandbox => scripts}/update_schema.sh (100%) rename app/{deploy => scripts}/wait.sh (82%) rename app/{deploy => scripts}/worker.sh (95%) rename app/{sandbox => }/settings.py (99%) rename app/{sandbox => }/urls.py (100%) delete mode 100644 env/build.yml rename {app/deploy => etc}/apt.list (100%) rename {app/deploy => etc}/nginx.conf (100%) diff --git a/.gitignore b/.gitignore index 78da6b0f..7267b3b1 100644 --- a/.gitignore +++ b/.gitignore @@ -17,6 +17,7 @@ sdist develop-eggs .installed.cfg *.directory +.init # Installer logs pip-log.txt diff --git a/app/deploy/nginx-dev.conf b/app/deploy/nginx-dev.conf deleted file mode 100644 index 164f71da..00000000 --- a/app/deploy/nginx-dev.conf +++ /dev/null @@ -1,28 +0,0 @@ -server_tokens off; - -server { - listen 80; - server_name nginx; - charset utf-8; - - access_log /var/log/nginx/app-access.log; - error_log /var/log/nginx/app-error.log; - - # max upload size - client_max_body_size 4096M; # adjust to taste - - # phpmyadmin - location /phpmyadmin/ { - proxy_pass http://phpmyadmin/; - #proxy_set_header Host $http_host; - #proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - #proxy_set_header X-Forwarded-Server $http_host; - #proxy_redirect / /phpmyadmin/; - #proxy_cookie_path / /phpmyadmin/; - } - - location / { - uwsgi_pass app:8000; - include /etc/nginx/uwsgi_params; - } -} diff --git a/app/manage.py b/app/manage.py index d18fd971..1f7f7d15 100755 --- a/app/manage.py +++ b/app/manage.py @@ -2,8 +2,6 @@ import os, sys if __name__ == "__main__": - os.environ.setdefault("DJANGO_SETTINGS_MODULE", "sandbox.settings") - + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings") from django.core.management import execute_from_command_line - execute_from_command_line(sys.argv) diff --git a/app/sandbox/robots.txt b/app/robots.txt similarity index 100% rename from app/sandbox/robots.txt rename to app/robots.txt diff --git a/app/sandbox/__init__.py b/app/sandbox/__init__.py deleted file mode 100644 index 40a96afc..00000000 --- a/app/sandbox/__init__.py +++ /dev/null @@ -1 +0,0 @@ -# -*- coding: utf-8 -*- diff --git a/app/deploy/app.sh b/app/scripts/app.sh similarity index 93% rename from app/deploy/app.sh rename to app/scripts/app.sh index 723fd388..dc8eb5cd 100644 --- a/app/deploy/app.sh +++ b/app/scripts/app.sh @@ -20,7 +20,7 @@ gid='www-data' # pip install django-angular # waiting for other network services -sh $app/deploy/wait.sh +sh $app/scripts/wait.sh # django setup python $manage wait-for-db @@ -31,7 +31,7 @@ python $manage collectstatic --noinput python $manage telemeta-create-admin-user python $manage telemeta-create-boilerplate -if [ $DEBUG = "False" ] +if [ $DEBUG == "False" ] then python $manage update_index --workers $processes & if [ ! -f .init ] @@ -41,7 +41,7 @@ then fi fi -if [ $1 = "--runserver" ] +if [ $1 == "--runserver" ] then python $manage runserver_plus 0.0.0.0:8000 else diff --git a/app/sandbox/diag.sh b/app/scripts/diag.sh similarity index 100% rename from app/sandbox/diag.sh rename to app/scripts/diag.sh diff --git a/app/sandbox/modelviz.py b/app/scripts/modelviz.py similarity index 100% rename from app/sandbox/modelviz.py rename to app/scripts/modelviz.py diff --git a/app/sandbox/update_schema.sh b/app/scripts/update_schema.sh similarity index 100% rename from app/sandbox/update_schema.sh rename to app/scripts/update_schema.sh diff --git a/app/deploy/wait.sh b/app/scripts/wait.sh similarity index 82% rename from app/deploy/wait.sh rename to app/scripts/wait.sh index a3341e05..02289edf 100644 --- a/app/deploy/wait.sh +++ b/app/scripts/wait.sh @@ -1,6 +1,6 @@ #!/bin/sh -apt-get install -y --force-yes netcat +# apt-get install -y --force-yes netcat set -e @@ -15,4 +15,4 @@ do sleep 1 done -echo 'ok' \ No newline at end of file +echo 'ok' diff --git a/app/deploy/worker.sh b/app/scripts/worker.sh similarity index 95% rename from app/deploy/worker.sh rename to app/scripts/worker.sh index 78d23a4e..76bb4652 100644 --- a/app/deploy/worker.sh +++ b/app/scripts/worker.sh @@ -9,7 +9,7 @@ wsgi=$app'/wsgi.py' # pip install django-environ redis # waiting for other services -sh $app/deploy/wait.sh +sh $app/scripts/wait.sh # Starting celery worker with the --autoreload option will enable the worker to watch for file system changes # This is an experimental feature intended for use in development only diff --git a/app/sandbox/settings.py b/app/settings.py similarity index 99% rename from app/sandbox/settings.py rename to app/settings.py index 5590b2ed..bc2f5600 100644 --- a/app/sandbox/settings.py +++ b/app/settings.py @@ -133,7 +133,7 @@ MIDDLEWARE_CLASSES = ( # 'pagination.middleware.PaginationMiddleware', ) -ROOT_URLCONF = 'sandbox.urls' +ROOT_URLCONF = 'urls' TEMPLATE_DIRS = ( # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates". diff --git a/app/sandbox/urls.py b/app/urls.py similarity index 100% rename from app/sandbox/urls.py rename to app/urls.py diff --git a/app/worker.py b/app/worker.py index b7779a0a..6d06656d 100644 --- a/app/worker.py +++ b/app/worker.py @@ -3,12 +3,13 @@ import os, sys from celery import Celery from django.conf import settings -sys.path.append(os.path.dirname('sandbox')) +sys.path.append(os.path.dirname('.')) +sys.path.append(os.path.dirname('..')) # set the default Django settings module for the 'celery' program. os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'settings') -app = Celery('sandbox') +app = Celery('app') # Using a string here means the worker will not have to # pickle the object when using Windows. diff --git a/app/wsgi.py b/app/wsgi.py index 58447f97..a16968d4 100644 --- a/app/wsgi.py +++ b/app/wsgi.py @@ -4,14 +4,14 @@ import os import sys -sys.path.append(os.path.dirname('sandbox')) +sys.path.append(os.path.dirname('.')) # os.environ['DJANGO_SETTINGS_MODULE'] = 'settings' # # import django.core.handlers.wsgi # application = django.core.handlers.wsgi.WSGIHandler() -os.environ.setdefault("DJANGO_SETTINGS_MODULE", "sandbox.settings") +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings") from django.core.wsgi import get_wsgi_application application = get_wsgi_application() diff --git a/docker-compose.yml b/docker-compose.yml index 95de519f..a6cef527 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -55,7 +55,7 @@ app: - data env_file: - env/prod.env - command: /bin/sh deploy/app.sh + command: /bin/sh scripts/app.sh links: - broker - db @@ -67,7 +67,7 @@ worker: - app env_file: - env/prod.env - command: /bin/sh deploy/worker.sh + command: /bin/sh scripts/worker.sh links: - broker - db @@ -77,7 +77,7 @@ nginx: ports: - "8000:80" volumes: - - ./app/deploy/nginx.conf:/etc/nginx/conf.d/default.conf + - ./etc/nginx.conf:/etc/nginx/conf.d/default.conf volumes_from: - data links: diff --git a/env/build.yml b/env/build.yml deleted file mode 100644 index 3ee1e4c0..00000000 --- a/env/build.yml +++ /dev/null @@ -1,28 +0,0 @@ -# -*- coding: utf-8 -*- -# -# Copyright (c) 2015-2016 Parisson SARL - -# This file is part of Telemeta. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 2 of the License, or -# (at your option) any later version. - -# TimeSide is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. - -# You should have received a copy of the GNU Affero General Public License -# along with TimeSide. If not, see . - -# Authors: -# Guillaume Pellerin -# Thomas Fillon - -app: - build: . - -worker: - build: . diff --git a/env/debug.yml b/env/debug.yml index 7a5301ab..d41b0df9 100644 --- a/env/debug.yml +++ b/env/debug.yml @@ -23,9 +23,6 @@ app: - volumes: - - ./app/:/srv/app - - ./telemeta/:/srv/src/telemeta/telemeta env_file: - env/debug.env diff --git a/env/dev.yml b/env/dev.yml index 4667e01e..2142946d 100644 --- a/env/dev.yml +++ b/env/dev.yml @@ -25,7 +25,7 @@ app: env_file: - env/debug.env - command: /bin/sh deploy/app.sh --runserver + command: /bin/sh scripts/app.sh --runserver ports: - 8000:8000 diff --git a/app/deploy/apt.list b/etc/apt.list similarity index 100% rename from app/deploy/apt.list rename to etc/apt.list diff --git a/app/deploy/nginx.conf b/etc/nginx.conf similarity index 100% rename from app/deploy/nginx.conf rename to etc/nginx.conf -- 2.39.5