ruby on Rails 3 在生产模式下不会调用 Rake 任务
从控制器:-
call_rake :parse_venue, :venue_list_id => venue_list.id
def call_rake(task, options = {})
options[:rails_env] ||= Rails.env
args = options.map { |n, v| "#{n.to_s.upcase}='#{v}'" }
system "rake #{task} #{args.join(' ')} --trace 2>&1 >> #{Rails.root}/log/rake.log &"
end
在开发模式下,此 rake 任务被触发。但在生产模式下,它不会被触发。
PS:- 灵感来自rake in后台,railscast。生产模式下 rake.log 文件中没有任何内容
From a controller:-
call_rake :parse_venue, :venue_list_id => venue_list.id
def call_rake(task, options = {})
options[:rails_env] ||= Rails.env
args = options.map { |n, v| "#{n.to_s.upcase}='#{v}'" }
system "rake #{task} #{args.join(' ')} --trace 2>&1 >> #{Rails.root}/log/rake.log &"
end
In development mode this rake task is triggered.. But in case of production mode its not triggered.
PS:- Inspired from rake in background, railscast. There is nothing in rake.log file in production mode
尝试以下系统调用:
Try the following system call: