0

我正在尝试创建一个重新启动我的 heroku 服务的 rake 任务。我发现这篇文章帮助很大:http ://railspikes.com/2010/2/13/rake-task-for-deploying-to-heroku 。

我拼凑了这个 rake 任务,但它给了我一个错误。我得到了消息:未初始化的常量 Heroku::Command::BaseWithApp。

这是我的方法。

desc 'restarts the server'
task restart_server: :environment do
  require 'heroku'
  require 'heroku/command'
  user, pass = File.read(File.expand_path("~/.heroku/credentials.txt")).split("\n")
  heroku = Heroku::Client.new(user, pass)

  cmd = Heroku::Command::BaseWithApp.new([])
  remotes = cmd.git_remotes(File.dirname(__FILE__) + "/../..")

  remote, app = remotes.detect {|key, value| value == (ENV['APP'])}# || cmd.app)}

  if remote.nil?
    raise "Could not find a git remote for the '#{ENV['APP']}' app"
  end

  heroku.restart(ENV['APP'])
end

我不确定它为什么拒绝 Heroku::Command。该应用程序已经在 Heroku 上运行,所以我知道它与 Heroku 兼容。

有什么建议吗?

编辑:这是我的堆栈跟踪。

** Invoke restart_server (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute restart_server
rake aborted!
uninitialized constant Heroku::Command::BaseWithApp
/Users/bendowney/Sites/ProblemChildApp/lib/tasks/scheduler.rake:51:in `block in <top (required)>'
/Users/bendowney/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `call'
/Users/bendowney/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `block in execute'
/Users/bendowney/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `each'
/Users/bendowney/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute'
/Users/bendowney/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain'
/Users/bendowney/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/Users/bendowney/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/Users/bendowney/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke'
/Users/bendowney/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/application.rb:116:in `invoke_task'
/Users/bendowney/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block (2 levels) in top_level'
/Users/bendowney/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `each'
/Users/bendowney/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block in top_level'
/Users/bendowney/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/Users/bendowney/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/application.rb:88:in `top_level'
/Users/bendowney/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/application.rb:66:in `block in run'
/Users/bendowney/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/Users/bendowney/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
/Users/bendowney/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/bin/rake:33:in `<top (required)>'
/Users/bendowney/.rvm/gems/ruby-1.9.3-p194@global/bin/rake:19:in `load'
/Users/bendowney/.rvm/gems/ruby-1.9.3-p194@global/bin/rake:19:in `<main>'
/Users/bendowney/.rvm/gems/ruby-1.9.3-p194@ProblemChildApp/bin/ruby_noexec_wrapper:14:in `eval'
/Users/bendowney/.rvm/gems/ruby-1.9.3-p194@ProblemChildApp/bin/ruby_noexec_wrapper:14:in `<main>'
Tasks: TOP => restart_server
4

0 回答 0