Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Set RAILS_DEFAULT_LOGGER before loading Rails in the command line script

  • Loading branch information...
commit c43dba99dbe902c8b0629ae319c4041416d7caea 1 parent 8058888
Brandon Keepers bkeepers authored
Showing with 3 additions and 8 deletions.
  1. +3 −8 lib/delayed/command.rb
11 lib/delayed/command.rb
View
@@ -1,6 +1,7 @@
require 'rubygems'
require 'daemons'
require 'optparse'
+require 'logger'
module Delayed
class Command
@@ -44,16 +45,10 @@ def daemonize
def run(worker_name = nil)
Dir.chdir(RAILS_ROOT)
+ # Set the default logger
+ Object.const_set :RAILS_DEFAULT_LOGGER, Logger.new(File.join(RAILS_ROOT, 'log', 'delayed_job.log'))
require File.join(RAILS_ROOT, 'config', 'environment')
-
- # Replace the default logger
- logger = Logger.new(File.join(RAILS_ROOT, 'log', 'delayed_job.log'))
- logger.level = ActiveRecord::Base.logger.level
- ActiveRecord::Base.logger = logger
- ActiveRecord::Base.clear_active_connections!
- Delayed::Worker.logger = logger
Delayed::Job.worker_name = "#{worker_name} #{Delayed::Job.worker_name}"
-
Delayed::Worker.new(@options).start
rescue => e
logger.fatal e
Please sign in to comment.
Something went wrong with that request. Please try again.