Browse Source

Ensures DB migration only happens on first instance

pull/248/head
Stéphane Meny 3 years ago
parent
commit
f9fc68024c
No known key found for this signature in database
GPG Key ID: 9D0AFEA988527923
  1. 12
      lib/tasks/cf.rake
  2. 4
      manifest.yml

12
lib/tasks/cf.rake

@ -0,0 +1,12 @@
namespace :cf do
desc "Only run on the first application instance"
task on_first_instance: :environment do
instance_index = -1
begin
instance_index = JSON.parse(ENV["VCAP_APPLICATION"])["instance_index"]
rescue StandardError
nil
end
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