Browse Source

Adjust script to break on instance index missing

pull/248/head
Stéphane Meny 3 years ago
parent
commit
30c598b161
No known key found for this signature in database
GPG Key ID: 9D0AFEA988527923
  1. 8
      lib/tasks/cf.rake

8
lib/tasks/cf.rake

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

Loading…
Cancel
Save