Deploying app to Heroku¶
Prepare Heroku.
See also “Getting Started with Python on Heroku”.
Cloning repository, and add remote repository.
$ git clone https://github.com/mkouhei/pgraph $ cd pgraph $ git remote add heroku <Heroku URL>
Enabling plugins
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.
Memcached Cloud
$ heroku addons:create memcachedcloud:30
See also Memcached Cloud
New Relic APM
$ heroku addons:create newrelic:wayne
See also New Relic APM
git push to Heroku.
$ git push heroku master
Change the scale your app.
$ heroku ps:scale worker=1
Runnig test locally¶
Use PostgreSQL as Celery backend¶
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
Cloning repository, and add remote repository.
$ git clone https://github.com/mkouhei/pgraph $ cd pgraph
Generate requirements.txt.
$ python -m venv /path/to/heroku-venv $ . /path/to/heroku-venv $ pip install -e . -e .[heroku]
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
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¶
Installing RabbitMQ, Memcached.
$ sudo apt-get install rabbitmq-server memcached
Cloning repository, and add remote repository.
$ git clone https://github.com/mkouhei/pgraph $ cd pgraph
Generate requirements.txt.
$ python setup.py --version $ pip install -e . -e .[heroku]
Running celery worker.
$ CONFIG_FILE=heroku.ini newrelic-admin run-program celery worker -c 1 -A pgraph.tasks --loglevel=info
Execute run script.
$ MEMCACHEDCLOUD_SERVERS=127.0.0.1:11211 newrelic-admin run-program sh run