我创建了一个简单的任务,该任务通过控制器“何时”从控制器运行方法。
set :environment, :development
env :PATH, ENV['PATH']
set :output, { :error => "log/error.log", :standard => 'log/cron.log' }
every 2.minutes do
runner "ParserController.test1"
end
def self.test1
puts "HELLO PARSER"
end
每次执行--update-crontab并等待2分钟时,我都会在日志中出现错误:
bundler: not executable: bin/rails
我尝试在不使用cron的情况下运行命令,并得到2个不同的结果:
第一个变体是
bundle exec bin/rails runner -e development 'ParserController.test1'
'bundler: not executable: bin/rails'
第二个变种是
bundle exec rails runner -e development 'ParserController.test1'
HELLO PARSER
答案 0 :(得分:0)
尝试添加env :GEM_PATH, ENV['GEM_PATH']
set :environment, :development
env :PATH, ENV['PATH']
env :GEM_PATH, ENV['GEM_PATH']
set :output, { :error => "log/error.log", :standard => 'log/cron.log' }
every 2.minutes do
runner "ParserController.test1"
end