【问题标题】:Commands in the "system" block works in console but NOT inside application“系统”块中的命令在控制台中有效,但在应用程序中无效
【发布时间】:2023-03-06 03:48:01
【问题描述】:

我已经有 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 工作人员...该任务在应用程序初始化期间完美运行。

当我在控制台中尝试时,这条线完美运行:

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、独角兽、nginx

【问题讨论】:

  • 我已经更新了日志@shime。
  • 这与system 有什么关系?在我看来,Bundler 警告您缺少 Gemfile。
  • 可能我错过了一些大事,但我真的想不通。奇怪的是,没有诸如“/var/www/sts/releases/20130422190645”之类的路径我不明白为什么它看起来在几天前的版本中
  • 这不是问题。您正在使用 Capistrano,可能将“/var/www/sts/current”指向“/var/www/sts/releases/20130422190645”
  • 不,@bilash.saha,这是我的ls -lah 结果:lrwxrwxrwx. 1 deployer deployer 36 Apr 25 06:36 current -&gt; /var/www/sts/releases/20130424193523

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


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 2015-06-21
    • 2015-08-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-09-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多