Browse Source

Ensures DB migration only happens on first instance (#248)

pull/251/head
Stéphane Meny 3 years ago committed by GitHub
parent
commit
2a5543994b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      lib/tasks/cf.rake
  2. 4
      manifest.yml

8
lib/tasks/cf.rake

@ -0,0 +1,8 @@
namespace :cf do
desc "Only run on the first application instance"
task on_first_instance: :environment do
# We expect this information to be always available or break otherwise
instance_index = JSON.parse(ENV["VCAP_APPLICATION"])["instance_index"]
exit(0) unless instance_index.zero?
end
end

4
manifest.yml

@ -1,10 +1,10 @@
--- ---
defaults: &defaults defaults: &defaults
buildpacks: buildpacks:
- https://github.com/cloudfoundry/ruby-buildpack.git - ruby_buildpack
processes: processes:
- type: web - type: web
command: rake db:migrate && bin/rails server command: bundle exec rake cf:on_first_instance db:migrate && bin/rails server
instances: 2 instances: 2
memory: 512M memory: 512M

Loading…
Cancel
Save