问题描述
我遇到了一些奇怪的问题,即我的delay_jobs生产失败。最后,我将其范围缩小到记录器。如果我注释掉我的log函数调用,则一切正常。但是,如果我尝试登录,则会在delay_job处理程序中得到它:
---!ruby / struct:Delayed :: PerformableMethod
对象:AR:User:1
方法::load_and_update_without_send_later
args:[]
|闭流
/opt/ruby/lib/ruby/1.8/logger.rb:504:在`write'
/opt/ruby/lib/ruby/1.8/logger.rb:504:in`在'synchronize'中写入'
/opt/ruby/lib/ruby/1.8/monitor.rb:242:in`'b'b $ b /opt/ruby/lib/ruby/1.8/logger.rb:496:in`在`add'中写'
/opt/ruby/lib/ruby/1.8/logger.rb:326:在`add'
/opt/ruby/lib/ruby/1.8/logger.rb:374:in`信息'
/home/rails/myapp.com/releases/20100203203031/app/models/gmail.rb:35:在`log'
我的记录器如下:
@@ error_log_file = File.open( #{RAILS_ROOT} /log/error.log,'a')
@@ error_log_file.sync = true
def log(msg)
msg.each | line |
line =#{Time.now.strftime('%H:%M:%S')}#{line}
@@ error_log_file.info(line)#这是第35行,其中
放置失败
放线
结束
结束
如果我评论
这是一个延迟的工作问题,还是与我的日志目录有关?符号链接(由标准的capistrano部署设置)?
也没有将任何内容写入我的error.log文件,也没有任何内容写入delay_job.log。完全陷入困境...
伍迪·彼得森(Woody Peterson)在这里发现了问题: b $ b
问题是:
临时解决方法(归功于Nathan Phelps):
非常适合我!
I'm suffering some weird issue where my delayed_jobs are failing in production. Finally I narrowed it down to the logger. If I comment out my log function calls, everything works. However if I try to log, I get this in the delayed_job handler:
--- !ruby/struct:Delayed::PerformableMethod
object: AR:User:1
method: :load_and_update_without_send_later
args: []
| closed stream
/opt/ruby/lib/ruby/1.8/logger.rb:504:in `write'
/opt/ruby/lib/ruby/1.8/logger.rb:504:in `write'
/opt/ruby/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/opt/ruby/lib/ruby/1.8/logger.rb:496:in `write'
/opt/ruby/lib/ruby/1.8/logger.rb:326:in `add'
/opt/ruby/lib/ruby/1.8/logger.rb:374:in `info'
/home/rails/myapp.com/releases/20100203203031/app/models/gmail.rb:35:in `log'
My logger looks like this:
@@error_log_file = File.open("#{RAILS_ROOT}/log/error.log", 'a')
@@error_log_file.sync = true
def log(msg)
msg.each do |line|
line = "#{Time.now.strftime('%H:%M:%S')} #{line}"
@@error_log_file.info(line) # this is line 35 where it's failing
puts line
end
end
If I comment out the line "@@error_log_file.sync = true", it also works.
Is this a delayed job problem, or could it be related to my log directory being a symbolic link (as setup by a standard capistrano deploy)?
Also nothing is being written to my error.log file and nothing is being written to delayed_job.log. Totally stumped...
Woody Peterson found the problem here: http://groups.google.com/group/delayed_job/browse_thread/thread/f7d0534bb6c7c83f/37b4e8ed7bfaba42
The problem is:
The temporary fix (credit to Nathan Phelps) is:
Works for me perfectly!
这篇关于日志在生产中无法正常工作并延迟工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!