heroku_san icon indicating copy to clipboard operation
heroku_san copied to clipboard

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

Open jikamens opened this issue 11 years ago • 6 comments

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?

jikamens avatar Jun 28 '13 15:06 jikamens

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.

kmayer avatar Aug 02 '13 03:08 kmayer

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.

BrentWheeldon avatar Mar 22 '14 20:03 BrentWheeldon

creating tasks are cumulative, so if tasks.rb is getting loaded twice, then the dependencies will be as well. hmmm

so you don't need to load tasks.rb in your rake file , that's only for Sinatra-like apps that don't have rail ties to load it for you.

On Sat, Mar 22, 2014 at 1:41 PM, Brent Wheeldon [email protected]:

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 railtiehttps://github.com/fastestforward/heroku_san/blob/master/lib/railtie.rb#L6everything 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 thishttps://github.com/fastestforward/heroku_san/blob/master/lib/heroku_san/tasks.rb#L322 ).

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.

Reply to this email directly or view it on GitHubhttps://github.com/fastestforward/heroku_san/issues/149#issuecomment-38363438 .

[email protected] | (808) 722-6142 (c)

kmayer avatar Mar 23 '14 00:03 kmayer

I was just following the instructions in the example. The fix I outlined above actually didn't work. I'll dig in more tomorrow and report back.

On Mar 22, 2014, at 8:59 PM, Ken Mayer [email protected] wrote:

creating tasks are cumulative, so if tasks.rb is getting loaded twice, then the dependencies will be as well. hmmm

so you don't need to load tasks.rb in your rake file , that's only for Sinatra-like apps that don't have rail ties to load it for you.

On Sat, Mar 22, 2014 at 1:41 PM, Brent Wheeldon [email protected]:

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 railtiehttps://github.com/fastestforward/heroku_san/blob/master/lib/railtie.rb#L6everything 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 thishttps://github.com/fastestforward/heroku_san/blob/master/lib/heroku_san/tasks.rb#L322 ).

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.

Reply to this email directly or view it on GitHubhttps://github.com/fastestforward/heroku_san/issues/149#issuecomment-38363438 .

[email protected] | (808) 722-6142 (c) — Reply to this email directly or view it on GitHub.

BrentWheeldon avatar Mar 23 '14 01:03 BrentWheeldon

I think I need a better example for rails apps; they just need new objects defined.

Sent from my iPhone

On Mar 22, 2014, at 6:08 PM, Brent Wheeldon [email protected] wrote:

I was just following the instructions in the example. The fix I outlined above actually didn't work. I'll dig in more tomorrow and report back.

On Mar 22, 2014, at 8:59 PM, Ken Mayer [email protected] wrote:

creating tasks are cumulative, so if tasks.rb is getting loaded twice, then the dependencies will be as well. hmmm

so you don't need to load tasks.rb in your rake file , that's only for Sinatra-like apps that don't have rail ties to load it for you.

On Sat, Mar 22, 2014 at 1:41 PM, Brent Wheeldon [email protected]:

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 railtiehttps://github.com/fastestforward/heroku_san/blob/master/lib/railtie.rb#L6everything 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 thishttps://github.com/fastestforward/heroku_san/blob/master/lib/heroku_san/tasks.rb#L322 ).

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.

Reply to this email directly or view it on GitHubhttps://github.com/fastestforward/heroku_san/issues/149#issuecomment-38363438 .

[email protected] | (808) 722-6142 (c) — Reply to this email directly or view it on GitHub. — Reply to this email directly or view it on GitHub.

kmayer avatar Mar 23 '14 05:03 kmayer

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!

BrentWheeldon avatar Mar 23 '14 13:03 BrentWheeldon