<commit_before># review-app

This is the Django project which provides the App Service for the Review App.

## Containers

From this repository, 2 Docker containers are built:

### onetouchapps/review-app

This is a production-ready Apache process hooked up to the Django WSGI module.

### onetouchapps/review-static

This is the collected static files from across the Django project, packaged
into a folder structure and served up by nginx.

## Development mode

### Getting set up

You will need these 2 installed before you can do any dev work with this repo:

  - [Docker](https://docs.docker.com/installation/#installation)

  - [Fig](http://www.fig.sh/install.html)

After you've installed these, you will need to run

``fig build``

You can then run a dev server, or run browser (BDD) tests, or run backend
(Django nose) tests.

### Running a dev server

You don't need to install any Python stuff or database things; to run a dev
server you:

``fig up``

This will run a dev server, accessible in a browser from your local machine
at port 8000 on your local Docker host:

  - if you are running a (U|Li)nix system, the address will most likely be
    127.0.0.1 [you will also likely have to ``alias docker='sudo docker'`` for
    scripts in this repo to work]

  - if you are running a Mac, the address can be obtained with ``boot2docker
    ip``

Note that this will use a local sqlite3 database file on your machine, inside
the repo, to allow for persistence of your test / dev data.

### Running BDD Browser tests

To run the BDD tests which will drive the code, written in Jasmine and
executed (in dev) against the Django dev server, you need:

  1. [node](http://nodejs.org/download/) installed

  2. all the node depenencies set up locally: ``nvm install``

Then you can run the BDD tests with:

``developer_test_scripts/run_browser_tests.sh``

This script preps a Postgres database and takes care of starting and stopping
the Django dev server (in its Fig container). Because it runs a fresh Postgres
container every time, it will not interfere with your usual dev data. *[Note:
you do not need Postgres installed on your host]*

Note also that before it will run, you will need the APP_SERVICE_URL
environment variable set to point to the location where the dev server normally
runs (e.g. ``http://192.168.59.103:8000``) See the previous section for how to
find the IP address.

### Running Django-only backend tests

Django Nose tests may be run from your host with:

``developer_test_scripts/run_backend_tests.sh``

## Environment Variables

For the various phases of this project's delivery cycle to function correctly,
certain environment variables need to be made available to the running<commit_msg>Add README note about log aggregation from dev processes<commit_after># review-app

This is the Django project which provides the App Service for the Review App.

## Containers

From this repository, 2 Docker containers are built:

### onetouchapps/review-app

This is a production-ready Apache process hooked up to the Django WSGI module.

### onetouchapps/review-static

This is the collected static files from across the Django project, packaged
into a folder structure and served up by nginx.

## Development mode

### Getting set up

You will need these 2 installed before you can do any dev work with this repo:

  - [Docker](https://docs.docker.com/installation/#installation)

  - [Fig](http://www.fig.sh/install.html)

After you've installed these, you will need to run

``fig build``

You can then run a dev server, or run browser (BDD) tests, or run backend
(Django nose) tests.

### Running a dev server

You don't need to install any Python stuff or database things; to run a dev
server you:

``fig up``

This will run a dev server, accessible in a browser from your local machine
at port 8000 on your local Docker host:

  - if you are running a (U|Li)nix system, the address will most likely be
    127.0.0.1 [you will also likely have to ``alias docker='sudo docker'`` for
    scripts in this repo to work]

  - if you are running a Mac, the address can be obtained with ``boot2docker
    ip``

Note that this will use a local sqlite3 database file on your machine, inside
the repo, to allow for persistence of your test / dev data.

### Running BDD Browser tests

To run the BDD tests which will drive the code, written in Jasmine and
executed (in dev) against the Django dev server, you need:

  1. [node](http://nodejs.org/download/) installed

  2. all the node depenencies set up locally: ``nvm install``

Then you can run the BDD tests with:

``developer_test_scripts/run_browser_tests.sh``

This script preps a Postgres database and takes care of starting and stopping
the Django dev server (in its Fig container). Because it runs a fresh Postgres
container every time, it will not interfere with your usual dev data. *[Note:
you do not need Postgres installed on your host]*

Note also that before it will run, you will need the APP_SERVICE_URL
environment variable set to point to the location where the dev server normally
runs (e.g. ``http://192.168.59.103:8000``) See the previous section for how to
find the IP address.

### Running Django-only backend tests

Django Nose tests may be run from your host with:

``developer_test_scripts/run_backend_tests.sh``

## Logs from dev and dev testing

Like the web servers in the containers, the Django logging system has also
been configured to send all output to stdout on the container. Therefore you
can capture all the log output from all the app container (and the postgres
container during browser tests) by running a Logspout container and directing
its output to the log aggregator of your choice (e.g. papertrail):

``docker pull progrium/logspout``
``docker run -d -v=/var/run/docker.sock:/tmp/docker.sock progrium/logspout syslog://logs.papertrailapp.com:12345`` (where "12345" is yout port at papertrail)

## Environment Variables

For the various phases of this project's delivery cycle to function correctly,
certain environment variables need to be made available to the running
{'fraction_non_alphanumeric': 0.06638186000657247, 'fraction_numerical': 0.011830430496220835, 'mean_word_length': 4.180425531914894, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 4, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '843934', 'n_tokens_mistral': 1752, 'n_tokens_neox': 1619, 'n_words': 901}