On my local machine I can do
QUEUES=a,b,c,d rake resque:work
And it processes those queues in that order. However, on Heroku Cedar I add this to my procfile:
worker: QUEUES=a,b,c,d exec bundle exec rake resque:work
And it crashes the app on deploy. I'm probably missing something dumb, but I'm stumped.
PS I prefix the command with exec because of a bug with resque not properly decrementing the worker count.
You shouldn't need the initial exec. The entry should look like this:
worker: bundle exec rake resque:work QUEUE=a,b,c,d
Use #hone's fork to properly clean up workers when they quit. In your Gemfile:
gem 'resque', git: 'https://github.com/hone/resque.git', branch: 'heroku', require: 'resque/server'
Related
I want to count the votes a user has given to an article and save it somewhere.
I want to check all the SQL INSERT or CREATE lines executed when we do something like:
>$ bundle exec rake db:reset
>$ bundle exec rake db:seed
>$ bundle exec rake test:prepare
Is there a way I can check the SQL commands in Ruby on Rails?
You can add a custom Rake task and use it whenever you need to log the SQL output:
task log: :environment do
ActiveRecord::Base.logger = Logger.new(STDOUT)
end
Now you can run:
bundle exec rake log db:reset
bundle exec rake log db:seed
bundle exec rake log test:prepare
See "Is it possible to output the SQL change scripts that 'rake db:migrate' produces?"
I have a Rails 3.2.14 app with a rake task that listens for gps coordinates. I'm implementing a new method of collecting gps data that doesn't require a rake task to listen. So I'm trying to kill the rake task(s) that are spun up on my production server.
I did a ps aux | grep rake to get a list of the rake instances I want to kill and issued a kill "pid" and even the ugly kill -9 "pid" but the rake tasks keeps respawning. There are three instances of the rake task that are running that I need to kill. Is there a better way to kill these rake tasks then what I'm doing? I've also tried doing a killall -9 rake but it says rake: no process found
Any thoughts on how to stop this task would be greatly appreciated.
Actually I was able to kill the rake processes via Capistrano through a Capistrano task I wrote a while back. This killed all instances, now to remove the task from my app entirely.
I have a Rails 3.2.8 app which is running nicely in development on my machine, with Postgres as the db backend for ActiveRecord. However, when I deploy my code to an EC2 server, either via capistrano or by rsync'ing my project to the EC2 instance, rake no longer lists any of the db: tasks:
$ rake -T
rake about # List versions of all Rails frameworks and the environment
rake assets:clean # Remove compiled assets
rake assets:precompile # Compile all the assets named in config.assets.precompile
rake doc:app # Generate docs for the app -- also available doc:rails, doc:guides, doc:plugins (options: TEMPLATE=/rdoc-t...
rake load_gml # Load GML source files into the environment database
rake log:clear # Truncates all *.log files in log/ to zero bytes
rake middleware # Prints out your Rack middleware stack
rake notes # Enumerate all annotations (use notes:optimize, :fixme, :todo for focus)
rake notes:custom # Enumerate a custom annotation, specify with ANNOTATION=CUSTOM
rake rails:template # Applies the template supplied by LOCATION=(/path/to/template) or URL
rake rails:update # Update configs and some other initially generated files (or use just update:configs, update:scripts, or u...
rake routes # Print out all defined routes in match order, with names.
rake secret # Generate a cryptographically secure secret key (this is typically used to generate a secret for cookie se...
rake stats # Report code statistics (KLOCs, etc) from the application
rake test # Runs test:units, test:functionals, test:integration together (also available: test:benchmark, test:profil...
rake test:recent # Run tests for {:recent=>"test:prepare"} / Test recent changes
rake test:single # Run tests for {:single=>"test:prepare"}
rake test:uncommitted # Run tests for {:uncommitted=>"test:prepare"} / Test changes since last checkin (only Subversion and Git)
rake time:zones:all # Displays all time zones, also available: time:zones:us, time:zones:local -- filter with OFFSET parameter,...
rake tmp:clear # Clear session, cache, and socket files from tmp/ (narrow w/ tmp:sessions:clear, tmp:cache:clear, tmp:sock...
rake tmp:create # Creates tmp directories for sessions, cache, sockets, and pids
rake -P also reports no db: tasks.
I'm guessing it's some sort of dependency problem, but I can't see what that would be since I'm declaring all my gem dependencies in a Bundler Gemfile. Postgres 9.2.1 is installed and working, but even if it wasn't I don't get why the rake task would vanish.
Any clues as to what's going on gratefully received!
And it turns out to be stupid-simple: I had copied the deploy.rb file from a previous project which didn't use ActiveRecord, so I hadn't set the role db:. I'm still not sure why that meant that the rsync'ed copy of my project also didn't have any rake db: tasks, but I'm not going to spend any more cycles worrying about that.
I need to monitor my delayed_job worker with god. It starts perfectly, but when i want to stop it using "sudo god stop dj" it says
Sending 'stop' command
The following watches were affected:
dj-0
But worker is still on(it processes tasks etc.)
I looked through sites providing their god configs for delayed_job and stop command wasn't specified there. Do I need to specify stop task for god config or smth?
I start delayed_job with w.start = "cd #{rails_root} && QUEUE=work_server1 bundle exec rake -f #{rails_root}/Rakefile RAILS_ENV=#{environment} --trace jobs:work"
I've solved this problem. The reason was that using "bundle exec" two processes were spawned and god was monitoring the wrong one. So I've just upgraded rake to not use "bundle exec" and it works.
How do i pass jvm arguments like Xmx to a rake task in jruby?
Am using rvm and running the rake task "rake db:migrate".
Thanks!
Rather that put the entire path, if jruby is already the Ruby you're using (for example, with rvm) such that just typing rake would be using jruby, you can use a double dash to send the arguments to the jvm.
Examples:
bundle exec rake -- -J-Xmx1024m (if you're using bundler)
rake -- -J-Xmx1024m
Found it!
jruby -J-Xmx2048m -S /home/prats/.rvm/gems/jruby-1.6.1#myapp/bin/rake db:migrate