Skip to content
This repository has been archived by the owner on Nov 7, 2018. It is now read-only.

Fixing loading to account for Gunicorn's multiple instances #777

Merged
merged 2 commits into from
May 4, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions cf.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
#!/bin/bash
echo "------ Starting APP ------"
if [ $CF_INSTANCE_INDEX = "0" ]; then
echo "----- Migrating Database -----"
python manage.py migrate --noinput
echo "----- Loading Agency Contacts -----"
python manage.py load_agency_contacts
fi
gunicorn foia_hub.wsgi:application --log-file -
12 changes: 0 additions & 12 deletions foia_hub/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,11 @@
https://docs.djangoproject.com/en/1.6/howto/deployment/wsgi/
"""
import os
import subprocess

from django.core.wsgi import get_wsgi_application
from dj_static import Cling
from foia_hub.settings.base import BASE_DIR


# If running on Cloud Foundry and using 0th instance apply migrations
# and load agency contacts
instance_id = os.getenv('CF_INSTANCE_INDEX')
if instance_id == '0':
subprocess.Popen(['echo', '"----- Applying Migrations -----"'])
subprocess.Popen(['python', 'manage.py', 'migrate', '--noinput'])
subprocess.Popen(['echo', '"-----Loading Agency Contacts -----"'])
subprocess.Popen(['python', 'manage.py', 'load_agency_contacts'])


if os.getenv("NEW_RELIC_LICENSE_KEY"):
import newrelic.agent
newrelic.agent.initialize(os.path.join(
Expand Down