18F / 2015-foia-hub

A consolidated FOIA request hub.
Other
48 stars 17 forks source link

Starting more than 1 instance: data loading and database changes #687

Closed khandelwal closed 9 years ago

khandelwal commented 9 years ago

if we're starting more than one instance, we need to only have one of those instances do data loading and database changes.

geramirez commented 9 years ago

I think we might be able to work around this issue by duplicating the app in the yaml file. The first only deploys one instance while updating the data and the second can deploy multiple instances, but doesn't update the database.

manifest file

---
# all applications use these settings and services
memory: 1G
instances: 1
applications:
- name: openfoia-staging
  path: .
  timeout: 180
  command: echo '---loading data---' & bash cf.sh
- name: openfoia-staging
  instances: 2
  path: .
  timeout: 180
  command: echo '---deploying---' & waitress-serve --port=$VCAP_APP_PORT foia_hub.wsgi:application
arowla commented 9 years ago

We solved a similar problem on FEC by using the CF_INSTANCE_INDEX https://github.com/18F/openFEC/blob/master/run_api.py

geramirez commented 9 years ago

@arowla This is great, thanks!

khandelwal commented 9 years ago

:heart: @arowla for jumping in and showing us how it's done. We're using your solution.

arowla commented 9 years ago

Glad y'all appreciated the drive-by. :car:

geramirez commented 9 years ago

Solved with 18F/foia-hub/pull/742