From b770a77c81fadf798fd89522c11153e60d47d3aa Mon Sep 17 00:00:00 2001 From: Pavel Turinsky Date: Mon, 20 Aug 2018 21:18:26 +0200 Subject: [PATCH] =?UTF-8?q?=C3=9Aprava=20Makefile=20a=20nastaven=C3=AD=20p?= =?UTF-8?q?ro=20Gimliho,=20hlavn=C4=9B=20testovac=C3=AD=20verze?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Makefile | 26 +++++++++++++------------- mamweb/settings_test.py | 8 ++++---- mamweb_test.ini | 14 ++++++++++++++ 3 files changed, 31 insertions(+), 17 deletions(-) create mode 100644 mamweb_test.ini diff --git a/Makefile b/Makefile index 9208dbc6..789e5a0c 100644 --- a/Makefile +++ b/Makefile @@ -63,8 +63,8 @@ schema_all.pdf: # Deploy to current *mamweb-test* directory deploy_test: - @if [ ${USER} != "www-mam" ]; then echo "Only possible by user www-mam"; exit 1; fi - @if [ `pwd` != "/akce/MaM/WWW/mamweb-test" ]; then echo "Only possible in /akce/MaM/WWW/mamweb-test"; exit 1; fi + @if [ ${USER} != "mam-web" ]; then echo "Only possible by user mam-web"; exit 1; fi + @if [ `pwd` != "/akce/mam/www/mamweb-test" ]; then echo "Only possible in /akce/mam/www/mamweb-test"; exit 1; fi @echo "Installing version from origin/test ..." git pull origin test git clean -f @@ -73,13 +73,13 @@ deploy_test: ./manage.py collectstatic --noinput (chown -R :mam . || true ) (chmod -R g+rX,go-w . || true ) - @echo Notifying apache about the change ... - touch mamweb/wsgi.py + @echo Restarting systemd unit + systemctl --user restart mamweb-test.service @echo Done. # Deploy to current *mamweb-prod* directory deploy_prod: - @if [ ${USER} != "mam-web" ]; then echo "Only possible by user www-mam"; exit 1; fi + @if [ ${USER} != "mam-web" ]; then echo "Only possible by user mam-web"; exit 1; fi @if [ `pwd` != "/akce/mam/www/mamweb-prod" ]; then echo "Only possible in /akce/mam/www/mamweb-prod"; exit 1; fi @echo "Backing up production DB ..." ( cd .. && ./backup_prod_db.sh ) @@ -92,22 +92,22 @@ deploy_prod: (chown -R :mam . || true ) (chmod -R g+rX,go-w . || true ) @echo Restarting systemd user unit for MaM web - systemctl --user restart mamweb-prod + systemctl --user restart mamweb-prod.service @echo Done. # Sync test media directory with production sync_test_media: - @if [ ${USER} != "www-mam" ]; then echo "Only possible by user www-mam"; exit 1; fi - @if [ `pwd` != "/akce/MaM/WWW/mamweb-test" ]; then echo "Only possible in /akce/MaM/WWW/mamweb-test"; exit 1; fi - rsync -av --delete /akce/MaM/WWW/mamweb-prod/media/ ./media + @if [ ${USER} != "mam-web" ]; then echo "Only possible by user mam-web"; exit 1; fi + @if [ `pwd` != "/akce/mam/www/mamweb-test" ]; then echo "Only possible in /akce/mam/www/mamweb-test"; exit 1; fi + rsync -av --delete /akce/mam/www/mamweb-prod/media/ ./media # Sync test database with production database sync_test_db: - @if [ ${USER} != "www-mam" ]; then echo "Only possible by user www-mam"; exit 1; fi - pg_dump mam-test -U mam > dump-test-`date +"%Y%m%d_%H%M"`.sql - pg_dump -Fc mam-prod -U mam > dump-prod.sql - pg_restore -c -d mam-test -U mam dump-prod.sql + @if [ ${USER} != "mam-web" ]; then echo "Only possible by user mam-web"; exit 1; fi + pg_dump mam_test > dump-test-`date +"%Y%m%d_%H%M"`.sql + pg_dump -Fc mam_prod > dump-prod.sql + pg_restore -c -d mam_test dump-prod.sql rm dump-prod.sql @echo Done. diff --git a/mamweb/settings_test.py b/mamweb/settings_test.py index 9ec14ca5..877b9ac0 100644 --- a/mamweb/settings_test.py +++ b/mamweb/settings_test.py @@ -25,11 +25,11 @@ INSTALLED_APPS += ( SECRET_KEY = ')^u=i65*zmr_k53a*@f4q_+ji^o@!pgpef*5&8c7zzv9l+zo)n' # SECURITY WARNING: don't run with debug turned on in production! -DEBUG = False +DEBUG = True TEMPLATE_DEBUG = False -ALLOWED_HOSTS = ['*.mam.mff.cuni.cz', 'atrey.karlin.mff.cuni.cz', 'mam.mff.cuni.cz'] +ALLOWED_HOSTS = ['*.mam.mff.cuni.cz', 'atrey.karlin.mff.cuni.cz', 'mam.mff.cuni.cz', 'mam-test.kam.mff.cuni.cz', 'gimli.ms.mff.cuni.cz'] # Database # https://docs.djangoproject.com/en/1.7/ref/settings/#databases @@ -37,8 +37,8 @@ ALLOWED_HOSTS = ['*.mam.mff.cuni.cz', 'atrey.karlin.mff.cuni.cz', 'mam.mff.cuni. DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql_psycopg2', - 'NAME': 'mam-test', - 'USER': 'mam', + 'NAME': 'mam_test', + 'USER': 'mam-web', 'TEST': { 'NAME': 'mam-test-testdb', }, diff --git a/mamweb_test.ini b/mamweb_test.ini new file mode 100644 index 00000000..87ad98b5 --- /dev/null +++ b/mamweb_test.ini @@ -0,0 +1,14 @@ +[uwsgi] +socket = /tmp/uwsgi-mamweb_test.sock +logto = /akce/mam/www/mamweb_test.log +chdir = /akce/mam/www/mamweb-test/ +home = /akce/mam/www/mamweb-test/ + +module = mamweb.wsgi +plugin = python +master = True +vacuum = True +chmod-socket = 666 +max-requests = 5000 +die-on-term=true +