【发布时间】:2013-12-01 07:55:29
【问题描述】:
MyApp 正在使用 rvm gemset 1.9.3@rails-3.2。它不是默认值。
我正在使用 gem 'whenever' 定期发送电子邮件通知。这是我的日程安排。rb:
every 1.minutes do
runner "MyModel.send_emails" # if ...
end
除非 gemset 1.9.3@rails-3.2 是默认值,否则 Cron 作业无法运行。我如何改进我的 schedule.rb 以便为我的调度程序使用其他 gemsets(不仅是默认的@global)。
我已阅读官方文档:whenever 和 rvm issues 以及关于“rvm gemsets for ever”的 stackoverflow 问题,但没有找到答案。
我尝试将以下代码(根据 RVM-Notes 中的建议)放在我的 shedule.rb 中:
job_type :runner, "{ cd #{@current_path} > /home/####/.rvm/gems/ruby-1.9.3-p448@
rails-3.2/bin/rails; } && RAILS_ENV=:environment bundle exec rails runner ':task' :output"
但它没有给出任何结果:
ERROR:
/home/###/.rvm/gems/ruby-1.9.3-p448@global/gems/bundler-1.3.5/lib/bundler/spec_set.rb:92
:in `block in materialize': Could not find i18n-0.6.5 in any of the sources
(Bundler::GemNotFound)
如何为 Rails gem 'whenever' 指定 rvm gemsets?非常感谢!
更新
1) 我尝试为我的 Gemfile 提供 rvm 符号,如下所示:
ruby=ruby-1.9.3-p448 # with # sign
ruby-gemset=rails-3.2 # with # sign
它没有给出任何结果。没有任何变化。
2) 我试图修改我的 ~/.rvmrc。使用捆绑包的完整路径进行实验,rails 给了我以下错误列表:
/usr/bin/env: ruby: No such file or directory
/usr/bin/env: ruby: No such file or directory
/bin/bash: bundle: command not found
/bin/bash: bundle: command not found
/usr/bin/env: ruby_executable_hooks/usr/bin/env: ruby_executable_hooks: No such file or directory
: No such file or directory
这里通过 job_type 实验:
#job_type :runner, "{ cd #{path}; } && RAILS_ENV=:environment bundle exec rails runner ':task' :output"
job_type :runner, "{ cd #{path}; } && RAILS_ENV=:environment /home/###/.rvm/gems/ruby-1.9.3-p448@global/bin/bundle exec rails runner ':task' :output"
#job_type :runner, "cd #{path} && RAILS_ENV=development /home/###/.rvm/gems/ruby-1.9.3-p448@global/bin/bundle exec /home/###/.rvm/gems/ruby-1.9.3-p448@rails-3.2/bin/rails runner ':task' :output"
【问题讨论】:
-
你碰巧尝试了 rvmrc 吗??
标签: ruby-on-rails ruby cron rvm whenever