Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jikamens opened this issue Jun 28, 2013 · 6 comments
Open

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

jikamens opened this issue Jun 28, 2013 · 6 comments
Labels

Comments

@jikamens
Copy link

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?

@kmayer
Copy link
Contributor

kmayer commented Aug 2, 2013

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.

@BrentWheeldon
Copy link

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.

@kmayer
Copy link
Contributor

kmayer commented Mar 23, 2014

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//issues/149#issuecomment-38363438
.

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

@BrentWheeldon
Copy link

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//issues/149#issuecomment-38363438
.

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

Reply to this email directly or view it on GitHub.

@kmayer
Copy link
Contributor

kmayer commented Mar 23, 2014

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//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.

@BrentWheeldon
Copy link

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
Labels
Projects
None yet
Development

No branches or pull requests

3 participants