From 7b859fcca1697086aa561746d1f04beea5ea4121 Mon Sep 17 00:00:00 2001 From: Martyn Inglis Date: Mon, 28 Nov 2016 09:39:56 +0000 Subject: [PATCH 1/5] Set up REDIS config. Switched OFF on DEV and by DEFAULT Switched ON for TESTS Switched ON on PREVIEW - STAGING - PRODUCTION URL set via ENV file - set in environment_test.sh. DEVS will need to update environment.sh. README updated. --- README.md | 1 + config.py | 7 ++++++- environment_test.sh | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 94f88a902..84988374c 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,7 @@ export LOADTESTING_API_KEY='FIRETEXT_SIMULATION_KEY' export FIRETEXT_API_KEY='FIRETEXT_ACTUAL_KEY' export STATSD_PREFIX='YOU_OWN_PREFIX' export NOTIFICATION_QUEUE_PREFIX='YOUR_OWN_PREFIX' +export REDIS_URL="redis://localhost:6379/0" "> environment.sh ``` diff --git a/config.py b/config.py index e6c0c68f2..179d8fcf3 100644 --- a/config.py +++ b/config.py @@ -40,6 +40,9 @@ class Config(object): # Prefix to identify queues in SQS NOTIFICATION_QUEUE_PREFIX = os.getenv('NOTIFICATION_QUEUE_PREFIX') + # URL of redis instance + REDIS_URL = os.getenv('REDIS_URL') + ########################### # Default config values ### ########################### @@ -133,7 +136,6 @@ class Config(object): STATSD_PORT = 8125 REDIS_ENABLED = False - REDIS_URL = "redis://localhost:6379/0" SENDING_NOTIFICATIONS_TIMEOUT_PERIOD = 259200 @@ -190,6 +192,7 @@ class Preview(Config): CSV_UPLOAD_BUCKET_NAME = 'preview-notifications-csv-upload' API_HOST_NAME = 'http://admin-api.internal' FROM_NUMBER = 'preview' + REDIS_ENABLED = True class Staging(Config): @@ -199,6 +202,7 @@ class Staging(Config): STATSD_ENABLED = True API_HOST_NAME = 'http://admin-api.internal' FROM_NUMBER = 'stage' + REDIS_ENABLED = True class Live(Config): @@ -208,6 +212,7 @@ class Live(Config): STATSD_ENABLED = True API_HOST_NAME = 'http://admin-api.internal' FROM_NUMBER = '40604' + REDIS_ENABLED = True configs = { diff --git a/environment_test.sh b/environment_test.sh index a74a81a86..1c9d57c2c 100644 --- a/environment_test.sh +++ b/environment_test.sh @@ -11,3 +11,4 @@ export LOADTESTING_API_KEY="loadtesting" export FIRETEXT_API_KEY="Firetext" export STATSD_PREFIX="stats-prefix" export NOTIFICATION_QUEUE_PREFIX='testing' +export REDIS_URL="redis://localhost:6379/0" From 84f89fb768ef448d0b47202fc90b8dcc436e237f Mon Sep 17 00:00:00 2001 From: Jenny Duckett Date: Tue, 29 Nov 2016 16:39:59 +0000 Subject: [PATCH 2/5] Update README - the bootstrap script needs to be run before the app will run, so mention that first - explain what run_celery_beat.sh is for and that it isn't required to run the app --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 94f88a902..324d0a0e6 100644 --- a/README.md +++ b/README.md @@ -57,6 +57,8 @@ Install [Postgres.app](http://postgresapp.com/). You will need admin on your mac ## To run the application +First, run `scripts/bootstrap.sh` to install dependencies and create the databases. + You need to run the api application and a local celery instance. There are two run scripts for running all the necessary parts. @@ -69,6 +71,8 @@ scripts/run_app.sh scripts/run_celery.sh ``` +Optionally you can also run this script to run the scheduled tasks: + ``` scripts/run_celery_beat.sh ``` From 687f217d7b5ef882188b2248b29e25a922b2b50d Mon Sep 17 00:00:00 2001 From: Martyn Inglis Date: Fri, 2 Dec 2016 10:09:36 +0000 Subject: [PATCH 3/5] Updated readme --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 84988374c..d45dd5e22 100644 --- a/README.md +++ b/README.md @@ -56,6 +56,11 @@ NOTES: Install [Postgres.app](http://postgresapp.com/). You will need admin on your machine to do this. +### Redis + +To switch redis on you'll need to install it locally. On a OSX we've used brew for this. + + ## To run the application You need to run the api application and a local celery instance. From cea48140f8077fb0e74bf6371e0c01cdacd2934c Mon Sep 17 00:00:00 2001 From: Martyn Inglis Date: Fri, 2 Dec 2016 10:11:31 +0000 Subject: [PATCH 4/5] Added README to tell users how tp switch REDIS on --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d45dd5e22..553adc702 100644 --- a/README.md +++ b/README.md @@ -58,7 +58,9 @@ Install [Postgres.app](http://postgresapp.com/). You will need admin on your mac ### Redis -To switch redis on you'll need to install it locally. On a OSX we've used brew for this. +To switch redis on you'll need to install it locally. On a OSX we've used brew for this. To use redis caching you need to switch it on by changing the config for development: + + REDIS_ENABLED = True ## To run the application From a67195a86db1d840752e49a6b2771448caed4cfc Mon Sep 17 00:00:00 2001 From: bandesz Date: Fri, 2 Dec 2016 14:45:33 +0000 Subject: [PATCH 5/5] Set http proxy params for Docker build --- docker/Dockerfile-build | 6 ++++-- docker/Makefile | 9 ++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/docker/Dockerfile-build b/docker/Dockerfile-build index 1ee7f1a54..872c8d323 100644 --- a/docker/Dockerfile-build +++ b/docker/Dockerfile-build @@ -1,13 +1,15 @@ FROM python:3.4-slim -ARG APT_HTTP_PROXY +ARG HTTP_PROXY +ARG HTTPS_PROXY +ARG NO_PROXY ENV PYTHONUNBUFFERED=1 \ DEBIAN_FRONTEND=noninteractive RUN \ echo "Install base packages" \ - && ([ -z "$APT_HTTP_PROXY" ] || echo "Acquire::http::Proxy \"${APT_HTTP_PROXY}\";\n" > /etc/apt/apt.conf.d/99HttpProxy) \ + && ([ -z "$HTTP_PROXY" ] || echo "Acquire::http::Proxy \"${HTTP_PROXY}\";\n" > /etc/apt/apt.conf.d/99HttpProxy) \ && apt-get update \ && apt-get install -y --no-install-recommends \ make \ diff --git a/docker/Makefile b/docker/Makefile index c4e905d51..ab9f9d444 100644 --- a/docker/Makefile +++ b/docker/Makefile @@ -7,4 +7,11 @@ help: .PHONY: build-build-image build-build-image: - docker build --pull -f Dockerfile-build -t govuk/notify-api-builder --build-arg APT_HTTP_PROXY="${HTTP_PROXY}" . + docker build \ + --pull \ + --build-arg HTTP_PROXY="${HTTP_PROXY}" \ + --build-arg HTTPS_PROXY="${HTTP_PROXY}" \ + --build-arg NO_PROXY="${NO_PROXY}" \ + -f Dockerfile-build \ + -t govuk/notify-api-builder \ + .