Deployment

Deploying on Heroku

Heroku is a cloud hosting service. This enables you to deploy a web app to a server without having a server of your own or knowing much about server administration. After you have a Heroku account and the local Heroku tools installed, deployment is as simple as pushing a Git repository to Heroku and setting a few environment variables.

Steps for deployment are as follows:

  1. If you haven’t already, follow the instructions Development to download and configure CAQE.

  2. Sign up for a Heroku account

  3. Download the Heroku Toolbelt

    $ wget -O- https://toolbelt.heroku.com/install-ubuntu.sh | sh
    
  4. Login to Heroku using your credentials:

    $ heroku login
    
  5. While in the root directory of your CAQE repository, link the repository with Heroku by running the following command, changing the optional <your-caqe-app> parameter to your desired subdomain (without this parameter, a random subdomain is generated.):

    $ heroku create <your-caqe-app>
    
  6. After running the command, make note of the server address.

  7. Make sure your audio stimulus files are in the src/caqe/static/audio directory and your configuration file is in test_configurations. Add the files to your git repository and commit the changes, e.g.:

    $ git add .
    $ git commit -m 'Configured CAQE for comparing the output of Robust PCA and REPET'
    
  8. Push your repository to Heroku.

    $ git push heroku master
    
  9. Set your secret key environment variables. You can set the environment variables in Heroku with the heroku config:set command. Use this command to set environment variables to the secret keys in secret_keys.py (generated from generate_key_file.py):

    $ heroku config:set SESSION_KEY='<your-session-key>'
    $ heroku config:set CSRF_SECRET_KEY='<your-csrf-secret-key>'
    
  10. Then set your configuration variables, specifying your config filename and the server address, e.g.:

    $ heroku config:set CAQE_CONFIG='<your-caqe-config>.cfg'
    $ heroku config:set APP_MODE='PRODUCTION'
    $ heroku config:set SERVER_ADDRESS='<your-caqe-app>.herokuapp.com'
    
  11. Now that our variables are set. Let’s set and create the database. First we have to enable Postgresql on Heroku. There are a number of different plans, but most likely the heroku-dev plan will be enough for us:

    $ heroku addons:create heroku-postgresql:hobby-dev
    
  12. Double check the command completed. If it did, the following command will not have output:

    $ heroku pg:wait
    
  13. Create and initialize the database.

    $ heroku run python src/create_db.py
    
  14. Now, ensure that at least one instance of the app is running:

    $ heroku ps:scale web=1
    

    Note

    Though when you actually start collecting data with your CAQE app, we recommend increasing the number of instances to at least 2.

  15. To test how your evaluation will appear to a Mechanical Turk worker, go to http://your-caqe-app.herokuapp.com/mturk_debug