Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

"rake <env> deploy" does deploy four times? #149

Open
jikamens opened this Issue · 6 comments

3 participants

Jonathan Kamens Ken Mayer Brent Wheeldon
Jonathan Kamens

We are using heroku_san with mongoid_rails_migrations (fixed version at git://github.com/quantopian/mongoid_rails_migrations) for a Ruby on Rails application built on top of ruby 2.0.0, rails 3.2.13, and MongoDB.

When we run "rake staging deploy" or "rake production deploy", it does the entire deploy process four times.

When we do the deploy with "-t", it claims that all four deployments are happening within a single invocation of the deploy rule.

We thought perhaps it was running the deployment separately on each dyno, but our staging environment has only 2: 1 web dyno and 1 worker. On the other hand, our production environment has 3 web dynos and 1 worker. I don't know if any of this is relevant.

Oddly, it doesn't always do this. For example, it doesn't seem to do it in automated builds run by our Jenkins server, even though those builds are using the same "rake staging deploy" command we type on the command line.

Has anyone else seen this before? Any pointers for how to troubleshoot it further?

Ken Mayer
Collaborator

heroku_san knows nothing about dynos

When you "deploy" what do you see? A deploy is simply a git push, after that, it's all up to Heroku.

HerokuSan creates targets, "staging", "production", etc. based on what's in your heroku.yml file. Perhaps you have multiple stages with the same name? Naming one of them "deploy" would also be terribly bad.

Brent Wheeldon

I'm seeing this, too. I have this in my Rakefile (we have a rails app):

if defined? HerokuSan
  require 'deploy/our_strategy'
  require 'deploy/our_stage'
  config_file = File.join(File.expand_path(File.dirname(__FILE__)), 'config', 'heroku.yml')
  HerokuSan.project = HerokuSan::Project.new(config_file, deploy: OurStrategy)
  HerokuSan.project.configuration = HerokuSan::Configuration.new(HerokuSan.project, OurStage)

  load 'heroku_san/tasks.rb'
end

If I comment out load 'heroku_san/tasks.rb' from heroku_san's railtie everything works as expected.

The rake task itself runs twice, and in each of those runs the target is duplicated. Or that's how it seems since there is blank line between runs 1 and 2, and runs 3 and 4 (presumably caused by this).

The way I was able to fix this was to require: false the heroku_san gem in my Gemfile, and then amend my Rakefile to look like:

if Rails.env.development?
  require 'heroku_san'

  require 'deploy/our_strategy'
  require 'deploy/our_stage'
  config_file = File.join(File.expand_path(File.dirname(__FILE__)), 'config', 'heroku.yml')
  HerokuSan.project = HerokuSan::Project.new(config_file, deploy: OurStrategy)
  HerokuSan.project.configuration = HerokuSan::Configuration.new(HerokuSan.project, OurStage)

  load 'heroku_san/tasks.rb'
end

I'm not sure my solution is the best way to get around this issue, but it seems to work for us.

Ken Mayer
Collaborator
Brent Wheeldon
Ken Mayer
Collaborator
Brent Wheeldon

Yep, redefining HerokuSan.project (and HerokuSan.project.configuration in our case) did the trick.

I've just looked over the example again and it doesn't mention requiring/loading the gem's rake tasks, so I must have been reading the wrong section somehow. Sorry about that!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.