“system”块中的命令在控制台中工作,但不在应用程序内部

时间:2013-04-24 19:45:22

标签: ruby-on-rails rvm capistrano bundler resque

自从我试图解决这个问题已经过了12个小时......这是:

在我的控制器中,我有一个这样的方法:

def restart_workers
      system("cd /var/www/sts/current && bundle exec rake RAILS_ENV=#{Rails.env.to_s} resque:restart_workers")

      redirect_to presets_path, :notice=>"Worker'lar yeniden yuklendi. Yeniden acilmalari birkac saniye surebilir."
  end

我想要的就是使用rake任务来重新启动我的Resque worker ...这个任务在应用程序初始化期间完美运行。

当我在我的控制台中尝试时,此行完美运行:

system("cd /var/www/sts/current && bundle exec rake RAILS_ENV=#{Rails.env.to_s} resque:restart_workers")

但是当我通过我的应用程序调用此方法时,我在unicorn.log中看到了以下错误:

/home/deployer/.rvm/gems/ruby-2.0.0-p0/gems/bundler-1.3.5/lib/bundler/definition.rb:16:in `build': /var/www/sts/releases/20130422190645/Gemfile not found (Bundler::GemfileNotFound)
    from /home/deployer/.rvm/gems/ruby-2.0.0-p0/gems/bundler-1.3.5/lib/bundler.rb:148:in `definition'
    from /home/deployer/.rvm/gems/ruby-2.0.0-p0/gems/bundler-1.3.5/lib/bundler.rb:116:in `setup'
    from /home/deployer/.rvm/gems/ruby-2.0.0-p0/gems/bundler-1.3.5/lib/bundler/setup.rb:17:in `<top (required)>'
    from /home/deployer/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
    from /home/deployer/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'

我真的被困了。

感谢任何帮助,谢谢!

仅供参考,我正在使用: RVM,Capistrano,Unicorn,nginx

1 个答案:

答案 0 :(得分:0)

感谢上帝,我在这篇博文中找到了我的问题的答案: http://blog.willj.net/2011/08/02/fixing-the-gemfile-not-found-bundlergemfilenotfound-error/