resque / resque/resque-scheduler
undefined method `namespace' for main:Object (NoMethodError)
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 1.7k
- Forks
- 477
- PR merge metrics
- No merged PRs in 30d
Description
Couldn't start my server after installing resque-scheduler.
Versions:
Using resque 1.25.2
Using rufus-scheduler 3.0.9
Using resque-scheduler 4.0.0
Gemfile:
gem 'resque', :require => "resque/server"
gem 'resque-scheduler'
Stack trace:
/Users/Will/.rvm/gems/ruby-2.0.0-p481@railstutorial_rails_4_0/gems/resque-1.25.2/lib/resque/tasks.rb:4:in <top (required)>': undefined methodnamespace' for main:Object (NoMethodError)
from /Users/Will/.rvm/gems/ruby-2.0.0-p481@railstutorial_rails_4_0/gems/activesupport-4.0.8/lib/active_support/dependencies.rb:229:in require' from /Users/Will/.rvm/gems/ruby-2.0.0-p481@railstutorial_rails_4_0/gems/activesupport-4.0.8/lib/active_support/dependencies.rb:229:inblock in require'
from /Users/Will/.rvm/gems/ruby-2.0.0-p481@railstutorial_rails_4_0/gems/activesupport-4.0.8/lib/active_support/dependencies.rb:214:in load_dependency' from /Users/Will/.rvm/gems/ruby-2.0.0-p481@railstutorial_rails_4_0/gems/activesupport-4.0.8/lib/active_support/dependencies.rb:229:inrequire'
from /Users/Will/.rvm/gems/ruby-2.0.0-p481@railstutorial_rails_4_0/gems/resque-scheduler-4.0.0/lib/resque/scheduler/tasks.rb:3:in <top (required)>' from /Users/Will/.rvm/gems/ruby-2.0.0-p481@railstutorial_rails_4_0/gems/activesupport-4.0.8/lib/active_support/dependencies.rb:229:inrequire'
from /Users/Will/.rvm/gems/ruby-2.0.0-p481@railstutorial_rails_4_0/gems/activesupport-4.0.8/lib/active_support/dependencies.rb:229:in block in require' from /Users/Will/.rvm/gems/ruby-2.0.0-p481@railstutorial_rails_4_0/gems/activesupport-4.0.8/lib/active_support/dependencies.rb:214:inload_dependency'
from /Users/Will/.rvm/gems/ruby-2.0.0-p481@railstutorial_rails_4_0/gems/activesupport-4.0.8/lib/active_support/dependencies.rb:229:in require' from /Users/Will/Google Drive/Driver Hunt/Code/driverhunt2/config/initializers/resque.rb:9:in<top (required)>'
from /Users/Will/.rvm/gems/ruby-2.0.0-p481@railstutorial_rails_4_0/gems/activesupport-4.0.8/lib/active_support/dependencies.rb:223:in load' from /Users/Will/.rvm/gems/ruby-2.0.0-p481@railstutorial_rails_4_0/gems/activesupport-4.0.8/lib/active_support/dependencies.rb:223:inblock in load'
from /Users/Will/.rvm/gems/ruby-2.0.0-p481@railstutorial_rails_4_0/gems/activesupport-4.0.8/lib/active_support/dependencies.rb:214:in load_dependency' from /Users/Will/.rvm/gems/ruby-2.0.0-p481@railstutorial_rails_4_0/gems/activesupport-4.0.8/lib/active_support/dependencies.rb:223:inload'
from /Users/Will/.rvm/gems/ruby-2.0.0-p481@railstutorial_rails_4_0/gems/railties-4.0.8/lib/rails/engine.rb:609:in block (2 levels) in <class:Engine>' from /Users/Will/.rvm/gems/ruby-2.0.0-p481@railstutorial_rails_4_0/gems/railties-4.0.8/lib/rails/engine.rb:608:ineach'
from /Users/Will/.rvm/gems/ruby-2.0.0-p481@railstutorial_rails_4_0/gems/railties-4.0.8/lib/rails/engine.rb:608:in block in <class:Engine>' from /Users/Will/.rvm/gems/ruby-2.0.0-p481@railstutorial_rails_4_0/gems/railties-4.0.8/lib/rails/initializable.rb:30:ininstance_exec'
from /Users/Will/.rvm/gems/ruby-2.0.0-p481@railstutorial_rails_4_0/gems/railties-4.0.8/lib/rails/initializable.rb:30:in run' from /Users/Will/.rvm/gems/ruby-2.0.0-p481@railstutorial_rails_4_0/gems/railties-4.0.8/lib/rails/initializable.rb:55:inblock in run_initializers'
Here's my initializers/resque.rb:
ENV["REDISTOGO_URL"] ||= "redis://127.0.0.1:6379/0"
uri = URI.parse(ENV["REDISTOGO_URL"])
Resque.redis = Redis.new(:host => uri.host, :port => uri.port, :password => uri.password, :thread_safe => true)
Dir["/app/app/workers/.rb"].each { |file| require file }
ENV['QUEUE'] ||= ''
require 'resque/scheduler/tasks'
Resque.schedule = YAML.load_file("#{Rails.root}/config/resque_schedule.yml")
My resque.rake:
Resque tasks
require "resque/tasks"
require 'resque/scheduler/tasks'
task "resque:setup" => :environment
namespace :resque do
task :setup => :environment do
ENV['QUEUE'] ||= '*'
#for redistogo on heroku http://stackoverflow.com/questions/2611747/rails-resque-workers-fail-with-pgerror-server-closed-the-connection-unexpectedl
Resque.before_fork = Proc.new { ActiveRecord::Base.establish_connection }
end
task :setup_schedule => :setup do
require 'resque-scheduler'
# If you want to be able to dynamically change the schedule,
# uncomment this line. A dynamic schedule can be updated via the
# Resque::Scheduler.set_schedule (and remove_schedule) methods.
# When dynamic is set to true, the scheduler process looks for
# schedule changes and applies them on the fly.
# Note: This feature is only available in >=2.0.0.
# Resque::Scheduler.dynamic = true
# The schedule doesn't need to be stored in a YAML, it just needs to
# be a hash. YAML is usually the easiest.
Resque.schedule = YAML.load_file("#{Rails.root}/config/resque_schedule.yml")
# If your schedule already has +queue+ set for each job, you don't
# need to require your jobs. This can be an advantage since it's
# less code that resque-scheduler needs to know about. But in a small
# project, it's usually easier to just include you job classes here.
# So, something like this:
require 'resque/scheduler/tasks'
end
task :scheduler_setup => :setup_schedule
end
desc "Alias for resque:work (To run workers on Heroku)"
task "jobs:work" => 'resque:work QUEUE="*"''
task "jobs:work" => 'resque:work'
My resque_schedule.yml
recommended_drivers_weekly:
cron: 0 8 * * 2
class: DriverRecommendationEmailSender
args:
description: Send recommended drivers email to employers
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with resque.rake and compare its requires with resque/tasks.rb and resque/scheduler/tasks.rb, using the stack trace to follow the load order from config/initializers/resque.rb. Reproduce the server startup failure with the listed Resque and resque-scheduler versions. Done means the tasks load without the undefined namespace error and the scheduler setup remains usable.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100