When I run
rake resque:scheduler RAILS_ENV=production
I get the following output:
2013-09-19 18:16:16 Reloading Schedule
2013-09-19 18:16:16 Loading Schedule
2013-09-19 18:16:16 Scheduling aa_job
2013-09-19 18:16:16 Scheduling bb_job
2013-09-19 18:16:16 Scheduling cc_aggregator
2013-09-19 18:16:16 Schedules Loaded
However I can see that none of this jobs get actually enqueued.I know my worker is up and running because if I do something like
Resque.enqueue(aa_job)
It gets enqueue and executed as expected.
Other thing, if I do Resque.schedule in my Rails console, I get {} (empty)
Any Ideas?
Thanks.
did you have workers on the corresponding queue?
resque_scheduler is only responsible for enqueueing jobs , i.e: you need to run both:
rake resque:scheduler RAILS_ENV=production and QUEUE=* rake resque:work
I've had the same problem. It appeared that there was another scheduler process started, and when I started one more, it wrote that it scheduled job, but actually it didn't. So I just restarted all scheduler processes and now it works fine for me.
I had the same issue, which was solved by loading environment in the scheduler rake task:
rake environment resque:scheduler RAILS_ENV=production
Related
I am trying to invoke a rake task in in my rspec.
require "rake"
rake = Rake::Application.new
Rake.application = rake
rake.init
rake.load_rakefile
rake['rake my:task'].invoke
But i am getting error
Failure/Error: rake['rake db:migrate'].invoke
RuntimeError:
Don't know how to build task 'rake db:migrate'
Does anyone have a idea how we can invoke rake task in rspec code.
Any help would be highly appreciated.
Small namespacing issue, the task is db:migrate not rake db:migrate like the command line usage.
So changing it to this should help:
rake['db:migrate'].invoke
A simpler solution for Rails with Rspec :
In your spec_helper (or rails_helper for newer versions of rspec-rails) :
require "rake"
Rails.application.load_tasks
Then when you want to invoke your task you can do the following :
Rake::Task['my:task'].invoke
To pass in the arguments in square brackets to invoke:
rake sim:manual_review_referral_program[3,4]
becomes:
rake['sim:manual_review_referral_program'].invoke(3,4)
If your args are in an array, you can do the following:
args = [3,4]
rake['sim:manual_review_referral_program'].invoke(*args)
More info at this StackOverflow question: How to run Rake tasks from within Rake tasks?.
I've been cap deploying my app all throughout it development, and this last time I tried to deploy it, it didn't work. Here's what happened:
* executing `deploy:assets:precompile'
* executing "cd /var/www/oneteam/releases/20121006153136 && bundle exec rake RAILS_ENV=production RAILS_GROUPS=assets assets:precompile"
servers: ["electricsasquatch.com"]
[electricsasquatch.com] executing command
** [out :: electricsasquatch.com] rake aborted!
** [out :: electricsasquatch.com] uninitialized constant OneTeam::Application::FactoryGirl
** [out :: electricsasquatch.com]
** [out :: electricsasquatch.com] (See full trace by running task with --trace)
It looks like it failed on the deploy:assets:precompile command. I don't get why that command would have tried to do anything with FactoryGirl, though. Any ideas?
It is not that something is wrong with deploy:assets:precompile task, but something is wrong with rake task that is using FactoryGirl. Even if you place a syntax error let us say in lib/tasks/first.rake and you execute task from lib/tasks/second.rake for instance rake second the rake will scream with rake aborted!. Even rake -T will not work. So there is rake task that is trying to use FactoryGirl but FactoryGirl is not included.
I had this in config/application.rb:
FactoryGirl.define do
sequence(:random_string) { |s| ('a'..'z').to_a.shuffle[0, 30].join }
end
I changed it to this:
if Rails.env != "production"
FactoryGirl.define do
sequence(:random_string) { |s| ('a'..'z').to_a.shuffle[0, 30].join }
end
end
The problem went away.
I am deploying rails project on heroku. When I use rake assets:precompile it gives following error -
rake aborted!
CScript Error: Execution of the Windows Script Host failed. (0x800A0007)
(in c:/Rails Projects/sheets_vip_rails/app/assets/javascripts/application.js)
Tasks: TOP => assets:precompile:primary
(See full trace by running task with --trace)
rake aborted!
Command failed with status (1): [c:/Ruby193/bin/ruby.exe c:/Ruby193/bin/rak...]
Tasks: TOP => assets:precompile
(See full trace by running task with --trace)
Thanks for any help.
All:
My error logs show heroku crashing on a rake task, rake jobs:work.
The problem is, I don't have a rake task called jobs or work. I only have one, called cron.
In that task, there's no Delayed Job stuff at all, and nowhere does the word 'jobs' or 'work' appear.
I've also looked in the Config files, and no trace of anything about Delayed Job. It's also not in Vendor/plugins.
Any ideas where the hidden rake task might be?
here's the error code:
2012-01-03T20:28:45+00:00 heroku[worker.3]: State changed from crashed to created
2012-01-03T20:28:45+00:00 heroku[worker.3]: State changed from created to starting
2012-01-03T20:28:48+00:00 heroku[worker.3]: Starting process with command `rake jobs:work`
2012-01-03T20:28:48+00:00 app[worker.3]: (in /app)
2012-01-03T20:28:48+00:00 heroku[worker.3]: State changed from starting to up
2012-01-03T20:28:49+00:00 app[worker.3]: rake aborted!
2012-01-03T20:28:49+00:00 app[worker.3]: Don't know how to build task 'jobs:work'
2012-01-03T20:28:49+00:00 app[worker.3]:
2012-01-03T20:28:49+00:00 app[worker.3]: (See full trace by running task with --trace)
2012-01-03T20:28:50+00:00 heroku[worker.3]: State changed from up to crashed
2012-01-03T20:28:51+00:00 heroku[worker.3]: Process exited
2012-01-03T20:28:53+00:00 app[web.9]:
Here's the --trace code
MacBook-Air:patientapp dougsmith$ heroku rake jobs:work --trace
(in /app)
rake aborted!
Don't know how to build task 'jobs:work'
/app/.bundle/gems/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:1728:in `[]'
/app/.bundle/gems/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:2050:in `invoke_task'
/app/.bundle/gems/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
/app/.bundle/gems/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `each'
/app/.bundle/gems/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
/app/.bundle/gems/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/app/.bundle/gems/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:2023:in `top_level'
/app/.bundle/gems/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:2001:in `run'
/app/.bundle/gems/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/app/.bundle/gems/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:1998:in `run'
/app/.bundle/gems/ruby/1.8/gems/rake-0.8.7/bin/rake:31
/app/.bundle/gems/ruby/1.8/bin/rake:19:in `load'
/app/.bundle/gems/ruby/1.8/bin/rake:19
MacBook-Air:patientapp dougsmith$
Do you have 1 or more Heroku worker dyno/s configured?
Looks like Heroku default Procfile run the command
worker bundle exec rake jobs:work
for Rails apps. Probably, editing/creating a procfile without this command makes the trick.
More info:
https://devcenter.heroku.com/articles/procfile
This happened to me. I found that delayed job had been in use before I started work on the site. A worker dyno was still configured for it. After removing that dyno the error went away.
I have upgraded a Rails 2.3.5 app to Rails 3.0.6. In the process I have also upgraded the resque from 1.9.1 to 1.15.0 and resque_scheduler from 1.9.1 to 1.9.9. The following commands used to work fine with Rails 2.3.5
COUNT=1 QUEUE=scheduled_1_queue,another_queue,yet_another_queue,slow_queue,redis_cleanup_queue,immediate_queue RAILS_ENV=development JOBS_PER_FORK=500 rake resque:workers
rake resque:scheduler
But now after the upgrade when I run above commands I get following error:
rake aborted!
wrong number of arguments (0 for 1)
Tasks: TOP => resque:work => resque:setup => environment
The RakeFile is as following:
require File.expand_path('../config/application', __FILE__)
require 'rake'
require 'resque/tasks'
require 'resque_scheduler/tasks'
MyApp::Application.load_tasks
task "resque:setup" => :environment
If i comment the last line 'task "resque:setup" => :environment' in RakeFile the resque scheduler and worker commands run without any error, but the scheduler does not schedule any tasks at all and stays on this:
2011-06-16 09:33:45 Schedule empty! Set Resque.schedule
I have also tried with older version of resque(1.9.1) and resque_scheduler(1.9.1) with Rails 3, but to no avail. I have also tried to run above commands with --trace, but it does not provide any trace info about the "wrong number of arguments (0 for 1)" error. I suspect I might need to provide more info, but don't know exactly what, please let me know what else is needed to answer this question. Thanks a lot.