diff --git a/lib/tasks/cf.rake b/lib/tasks/cf.rake new file mode 100644 index 000000000..111ea7395 --- /dev/null +++ b/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 diff --git a/manifest.yml b/manifest.yml index 154e816ef..5935f2495 100644 --- a/manifest.yml +++ b/manifest.yml @@ -1,10 +1,10 @@ --- defaults: &defaults buildpacks: - - https://github.com/cloudfoundry/ruby-buildpack.git + - ruby_buildpack processes: - type: web - command: rake db:migrate && bin/rails server + command: bundle exec rake cf:on_first_instance db:migrate && bin/rails server instances: 2 memory: 512M