I have an application with resque and resque-scheduler configured. The jobs all run fine and resque logs output to its log file. The resque-scheduler alos works fine, loading and processing the jobs as expected.
The one problem I have is the scheduler does not seem to log anything to its log file.
I followed the setup instructions here
https://github.com/resque/resque-scheduler#logging
And have this code in my initializer.
# Define the location of the schedule
Resque.schedule = YAML.load_file(Rails.root.join('config', 'scheduled_jobs.yml'))
# Define the logger
Resque::Scheduler.configure do |c|
c.quiet = false
c.verbose = false
c.logfile = File.open("#{Rails.root}/log/resque_scheduler.log", 'w+')
c.logformat = 'text'
end
When the application is started the resque_scheduler.log is created.
When I start the scheduler it outputs the following to the stdout (terminal window on my VM). I would have expected this to have gone into the log file.
$ rake resque:scheduler TERM_CHILD=1
resque-scheduler: [INFO] 2015-07-17T14:34:27+01:00: Starting
resque-scheduler: [INFO] 2015-07-17T14:34:27+01:00: Loading Schedule
resque-scheduler: [INFO] 2015-07-17T14:34:27+01:00: Scheduling daily_job_email_overdue_items_to_admin
resque-scheduler: [INFO] 2015-07-17T14:34:27+01:00: Scheduling daily_job_to_update_status_to_overdue
resque-scheduler: [INFO] 2015-07-17T14:34:27+01:00: Schedules Loaded
I've done a search of the internet but haven't found anyone with the same problem. Anyone experienced the same problem or has it working and can suggest what I am missing.
Many thanks.
The solution is to use the LOGFILE environment variable when creating the rake task. If the file doesn't exist then it will create it anyway. The basic rake task to start the scheduler that specifies the log file is as follows.
rake resque:scheduler LOGFILE=./log/resque_scheduler.log
Feel a bit stupid that that I didn't think of this before. I had just assumed the scheduler would work in the same way as resque and grab the logfile details from the initializer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With