Skip to content

Commit

Permalink
No more heroku. Only one Procfile.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason Sanford committed Sep 4, 2013
1 parent 414c456 commit 015b8ee
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 44 deletions.
4 changes: 2 additions & 2 deletions Procfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
web: gunicorn gitspatial.wsgi --settings=gitspatial.settings.production
celery: python manage.py celery worker -E -B --loglevel=INFO
web: gunicorn gitspatial.wsgi --settings=gitspatial.settings.development -b 0.0.0.0:8000
celery: python manage.py celery worker -E -B --loglevel=DEBUG
2 changes: 0 additions & 2 deletions Procfile-dev

This file was deleted.

41 changes: 8 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ GitHub now supports [rendering GeoJSON files](https://help.github.com/articles/m

## How it Works

1. Visit http://gitspatial.herokuapp.com
1. Visit http://gitspatial.com
2. Authorize the site to access your GitHub repos
3. Sync the repos that have GeoJSON in them
4. Sync individual GeoJSON files within these repos
Expand All @@ -18,13 +18,13 @@ GitHub now supports [rendering GeoJSON files](https://help.github.com/articles/m

Find all parks within a map view:

http://gitspatial.herokuapp.com/api/v1/JasonSanford/mecklenburg-gis-opendata/parks?bbox=-81.025,35.023,-80.685,35.487
http://gitspatial.com/api/v1/JasonSanford/mecklenburg-gis-opendata/parks?bbox=-81.025,35.023,-80.685,35.487

### Search by Point and Radius

Find all parks within 3000 meters of a point:

http://gitspatial.herokuapp.com/api/v1/JasonSanford/mecklenburg-gis-opendata/parks?lat=35.255&lon=-80.855&distance=3000
http://gitspatial.com/api/v1/JasonSanford/mecklenburg-gis-opendata/parks?lat=35.255&lon=-80.855&distance=3000

## Development

Expand All @@ -38,7 +38,7 @@ GitSpatial is a Django app that uses PostGIS as a backend to GeoDjango. So, you

### Virtual Environment

Create a virtual environment. Python 2.7 is ideal as this is what Heroku uses. I drop the virtual envrionment within the root of the project. The `venv` directory is in `.gitignore`.
Create a virtual environment. I drop the virtual envrionment within the root of the project. The `venv` directory is in `.gitignore`.

virtualenv venv

Expand All @@ -59,8 +59,6 @@ To keep secret keys, passwords and such out of version control, we store them in
DATABASE_URL=postgis://user:password@host:port/db_name
GITHUB_APP_ID=not-a-secret
GITHUB_API_SECRET=super-secret
LD_LIBRARY_PATH=/app/.heroku/vendor/lib:vendor/geos/geos/lib:vendor/proj/proj/lib:vendor/gdal/gdal/lib
LIBRARY_PATH=/app/.heroku/vendor/lib:vendor/geos/geos/lib:vendor/proj/proj/lib:vendor/gdal/gdal/lib

### Database Stuff

Expand All @@ -70,40 +68,17 @@ Assuming you have a database already created and credentials are in the `DATABAS

### Running the App

The django web server (gunicorn) and the celery process are defined in `Procfile` and `Procfile-dev` and point to production and development settings respectively. Run with `Foreman`. Heroku will look for `Procfile`, while we'll use `Procfile-dev` locally.
The django web server (gunicorn) and the celery process are defined in `Procfile`. Run with `Foreman`.

foreman start -f Procfile-dev

## Deployment

### Web App

The application is currently hosted at heroku. Deployments are handled by `git push`'ing to a heroku endpoint. The current git remote is `git@heroku.com:gitspatial.git`

Add this remote to enable pushing.

git remote add heroku git@heroku.com:gitspatial.git

Then, deploying the latest code is just `git push heroku master`.

A [custom buildpack](https://github.com/JasonSanford/heroku-buildpack-python-geos) is used to include the GEOS, GDAL and Proj binaries necessary for Shapely and GeoDjango. To force deployment to use a custom buildpack, add the following heroku config.

heroku config:set BUILDPACK_URL=git://github.com/JasonSanford/heroku-buildpack-python-geos.git

Additionally, the `LIBRARY_PATH` and `LD_LIBRARY_PATH` enverionment variables must be updated so that Shapely can locate the necessary binaries.

heroku config:set LIBRARY_PATH=/app/.heroku/vendor/lib:vendor/geos/geos/lib:vendor/proj/proj/lib:vendor/gdal/gdal/lib
heroku config:set LD_LIBRARY_PATH=/app/.heroku/vendor/lib:vendor/geos/geos/lib:vendor/proj/proj/lib:vendor/gdal/gdal/lib
foreman start -f Procfile

### Static Files

Static file deployment is handled by the `collectstatic` method when pushing to Heroku. We're using a combination of django-store and boto to automatically collect/push static files to Amazon S3 during deployment.
Static file deployment is handled by the `collectstatic` command. We're using a combination of django-store and boto to automatically collect/push static files to Amazon S3 during deployment.

All static files should be placed in the `/static` directory if they need to be deployed.

**Note!** - With the custom buildpack, collectstatic doesn't seem to be running automatically. To run manually:

heroku run python manage.py collectstatic
python manage.py collectstatic

## Testing

Expand Down
2 changes: 1 addition & 1 deletion gitspatial/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Repo(Syncable, Timestampable, models.Model):

@property
def hook_url(self):
return 'http://gitspatial.herokuapp.com/api/v1/hooks/{0}'.format(self.id)
return 'http://gitspatial.com/api/v1/hooks/{0}'.format(self.id)

def __unicode__(self):
return self.full_name
Expand Down
2 changes: 1 addition & 1 deletion gitspatial/user/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def user_feature_set(request, feature_set_id):
context = {
'feature_set': feature_set,
'api_url': '{0}{1}'.format(
'http://gitspatial.herokuapp.com',
'http://gitspatial.com',
reverse('v1_feature_set_query', kwargs={'user_name': feature_set.repo.user.username, 'repo_name': feature_set.repo.name, 'feature_set_name': feature_set.name})),
'count': count,
'center_lat': feature_set.center[1],
Expand Down
10 changes: 5 additions & 5 deletions templates/api_v1.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ <h2>API v1</h2>

<h3>The Resource</h3>

<pre>http://gitspatial.herokuapp.com/:user_name/:repo_name/:feature_set_name</pre>
<pre>http://gitspatial.com/:user_name/:repo_name/:feature_set_name</pre>

<table class="table table-bordered table-striped table-condensed">
<tbody>
Expand All @@ -31,7 +31,7 @@ <h3>The Resource</h3>

<h3>Search by Bounding Box</h3>

<pre>http://gitspatial.herokuapp.com/:user_name/:repo_name/:feature_set_name?bbox=:xmin,:ymin,:ymax,:ymax</pre>
<pre>http://gitspatial.com/:user_name/:repo_name/:feature_set_name?bbox=:xmin,:ymin,:ymax,:ymax</pre>

<h4>Parameters</h4>

Expand All @@ -48,11 +48,11 @@ <h4>Example</h4>

<p>Find parks in a map window.</p>

<pre>http://gitspatial.herokuapp.com/api/v1/JasonSanford/mecklenburg-gis-opendata/parks?bbox=-80.8633,35.2071,-80.8158,35.2488</pre>
<pre>http://gitspatial.com/api/v1/JasonSanford/mecklenburg-gis-opendata/parks?bbox=-80.8633,35.2071,-80.8158,35.2488</pre>

<h3>Search by Point and Radius</h3>

<pre>http://gitspatial.herokuapp.com/:user_name/:repo_name/:feature_set_name?lat=:latitude&lon=:longitude&distance=:distance</pre>
<pre>http://gitspatial.com/:user_name/:repo_name/:feature_set_name?lat=:latitude&lon=:longitude&distance=:distance</pre>

<table class="table table-bordered table-striped table-condensed">
<tbody>
Expand All @@ -75,7 +75,7 @@ <h4>Example</h4>

<p>Find schools within 4,000 meters of a point.</p>

<pre>http://gitspatial.herokuapp.com/api/v1/JasonSanford/mecklenburg-gis-opendata/data/schools.geojson?lat=35.256&lon=-80.809&distance=4000</pre>
<pre>http://gitspatial.com/api/v1/JasonSanford/mecklenburg-gis-opendata/data/schools.geojson?lat=35.256&lon=-80.809&distance=4000</pre>

<h3>Other Parameters</h3>

Expand Down

0 comments on commit 015b8ee

Please sign in to comment.