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...