Deploying app to Heroku

  1. Prepare Heroku.

    See also “Getting Started with Python on Heroku”.

  2. Cloning repository, and add remote repository.

    $ git clone https://github.com/mkouhei/pgraph
    $ cd pgraph
    $ git remote add heroku <Heroku URL>
    
  3. Enabling plugins

    1. Heroku Postgres

      $ heroku addons:create heroku-postgresql:hobby-dev
      

      See also Heroku Postgres

      Note

      If you will use CloudAMQP instead of Heroku Postgres, execute this.

      $ heroku addons:create cloudamqp:lemur
      

      See also CloudAMQP.

    2. Memcached Cloud

      $ heroku addons:create memcachedcloud:30
      

      See also Memcached Cloud

    3. New Relic APM

      $ heroku addons:create newrelic:wayne
      

      See also New Relic APM

  1. git push to Heroku.

    $ git push heroku master
    
  2. Change the scale your app.

    $ heroku ps:scale worker=1
    

Runnig test locally

Use PostgreSQL as Celery backend

  1. Installing PostgreSQL, Memcached.

    $ sudo apt-get install postgresql memcached
    $ sudo su - postgres
    $ psql
    postgres=# CREATE USER pgraph WITH PASSWORD 'passw0rd';
    postgres=# CREATE DATABASE pgraph OWNER pgraph;
    postgres=# \q
    

    Note

    You can use yrmcds instead of memcached.:

    $ sudo apt-get install yrmcds
    
  2. Cloning repository, and add remote repository.

    $ git clone https://github.com/mkouhei/pgraph
    $ cd pgraph
    
  3. Generate requirements.txt.

    $ python -m venv /path/to/heroku-venv
    $ . /path/to/heroku-venv
    $ pip install -e . -e .[heroku]
    
  4. Running celery worker.

    $ DATABSE_URL=postgres://pgraph:passw0rd@locahost:5432/pgraph CONFIG_FILE=heroku.ini newrelic-admin run-program celery worker -c 1 -A pgraph.tasks --loglevel=info
    
  5. Execute run script.

    $ DATABASE_URL=postgres://pgraph:passw0rd@localhost:5432/pgraph MEMCACHEDCLOUD_SERVERS=127.0.0.1:11211 newrelic-admin run-program sh run
    

Use RabbigMQ as Celery backend

  1. Installing RabbitMQ, Memcached.

    $ sudo apt-get install rabbitmq-server memcached
    

    Note

    You can use yrmcds instead of memcached.:

    $ sudo apt-get install yrmcds
    
  2. Cloning repository, and add remote repository.

    $ git clone https://github.com/mkouhei/pgraph
    $ cd pgraph
    
  3. Generate requirements.txt.

    $ python setup.py --version
    $ pip install -e . -e .[heroku]
    
  4. Running celery worker.

    $ CONFIG_FILE=heroku.ini newrelic-admin run-program celery worker -c 1 -A pgraph.tasks --loglevel=info
    
  5. Execute run script.

    $ MEMCACHEDCLOUD_SERVERS=127.0.0.1:11211 newrelic-admin run-program sh run