title: issues with elastic beanstalk leader election
body: <p>We have a rails app that has been working fine for months. Today we discovered some inconsistencies with leader election. Primarily:</p>
  
  <pre><code>su - "leader_only bundle exec rake db:migrate" webapp
  </code></pre>
  
  <p>After many hours of trial and error (and dozens of deployments) none of the instances in our dev application run this migration. <code>/usr/bin/leader_only</code> looks for an environment variable that is never set on any instance (the dev app has only one instance). </p>
  
  <p>Setting the application deployment to 1 instance at a time and providing the value that <code>/usr/bin/leader_only</code> expects as an env var works, but not as it has been and should. (Now all instances are leaders so they will fruitlessly run db:migrate and it's 1 at a time, so if we have many instances this will slow us down)</p>
  
  <p>We thought maybe it was due to some issues with the code and/or app, so we rebuilt it. No change. </p>
  
  <p>I even cloned our test application's RDS server and created a new application from a saved configuration, deployed a new git hash, and it never ran db:migrate as well. It attempts to and shows the leader_only line, but it never runs. That rules out code, configuration, artifacts. </p>
  
  <p>Also for what its worth, it never says skipping migrations due to RAILS_SKIP_MIGRATIONS, which has a value of false. This means that it is in fact trying to run db:migrate but isn't due to not being described as the leader.</p>