Queue_Classic: How to run the rake task automatically on Heroku without Procfile - ruby-on-rails-3

i need to know how to run the queue_classic (rake qc:work) rake task automatically on Heroku. I tried with Procfile, but i am using Bamboo and i get the next error: "Heroku push rejected, Procfile is not supported on the Bamboo stack"
any idea??
Thanks.

On heroku there is a addon viz heroku-scheduler, its free. Add this addon to your application. It will appear in your application addon lists, click it, and you will lead to worker dashboard where you can add job for example
bundle exec rake task_name
and schedule the task.

Related

Uable to run migration on heroku on a postgre database

I need to add a property/column to a table in a production database(Postgre) on Heroku.com (Rails app) by doing migration.
When I do the migration it looks ok, but when I view the columns on the table it has has not added the column!
My development db is sqlite3 and the production db is postgre
I do the following:
heroku run rails generate migration AddUtc_OffsetToEvents utc_offset:integer RAILS_ENV=production --app app-name-1111
and it returns:
invoke active_record
create db/migrate/20130304070946_add_utc_offset_to_events.rb
And then I run the migration
heroku run rake db:migrate RAILS_ENV=production --app app-name-1111
And then:
heroku restart
When I run
heroku pg:psql HEROKU_POSTGRESQL_GRAY_URL --app app-name-1111
and check the columns of the table:
\d+ events
It still does not have the utc_offset column, and no errors are displyed while doing the previous cmds.
Any ideas or hints?
It looks like you are doing several calls to heroku run
Each time you do heroku run it spins up a completely new dyno with your latest code, and when run is over that dyno is destroyed. So the second heroku run does not have the migration filed created in the first.
Since you are already familiar with psql you can just use ALTER TABLE directly. Otherwise you'll need to check your migration into your code and git push heroku master it to heroku, then run it.
Why not just download the code, add the migration and push the changes ?
After, just run the heroku run rake db:migrate on the app.

How can I run oink in heroku?

I'm having a problem running the oink gem on my app in Heroku. I've included it in my gemfile and gemfile.lock, uploaded those, and it installs. It even creates the oink.log (which I have no way of viewing, unfortunately). When I run
heroku run bundle exec oink --threshold=0 log/* --app my_app
I get
Running bundle exec oink --threshold=0
log/delayed_job.log log/development.log log/oink.log log/production.log log/test.log attached to terminal... up, run.3
/app/.bundle/gems/ruby/1.8/gems/oink-0.9.3/bin/../lib/oink/cli.rb:88:in get_file_listing':
Could not find "log/delayed_job.log" (RuntimeError)
from /app/.bundle/gems/ruby/1.8/gems/oink-0.9.3/bin/../lib/oink/cli.rb:86:ineach'
from /app/.bundle/gems/ruby/1.8/gems/oink-0.9.3/bin/../lib/oink/cli.rb:86:in get_file_listing'
from /app/.bundle/gems/ruby/1.8/gems/oink-0.9.3/bin/../lib/oink/cli.rb:59:inprocess'
from /app/.bundle/gems/ruby/1.8/gems/oink-0.9.3/bin/oink:4
from /app/.bundle/gems/ruby/1.8/bin/oink:19:in 'load'
from /app/.bundle/gems/ruby/1.8/bin/oink:19
I've tried running each of the individual files, too, and get the same result. This command runs fine on my local machine.
In my production.rb file, I have
config.logger = Hodel3000CompliantLogger.new(config.paths.log.first)
config.middleware.use( Oink::Middleware )
as configuration.
Can you enlighten me on what I'm doing wrong here? My understanding is that the logs are read only, but I don't know if that means they're only accessible through the heroku logs command. If there's a way I can see the oink.log file, too--knowing how to do that is also appreciated, or knowing how to see it in the actual Heroku log using heroku logs.
UPDATE: The configuration for oink shown above allows the commands to be run successfully on my localhost.
Thanks!
-Andrew

Bundler::GemNotFound when compiling assets from cap deploy

I'm deploying to servers with capistrano and doing a bundle exec rake RAILS_ENV=production RAILS_GROUPS=assets assets:precompile as the last step. Problem is when it gets to this point FROM cap deploy, i get the following error:
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/bundler-1.1.4/lib/bundler/spec_set.rb:90:in `block in materialize': Could not find Platform-0.4.0 in any of the sources (Bundler::GemNotFound)
Platform-0.4.0 IS in fact on the server. And when i go into the server and run this exact command, all works great.
Couple of facts about my server: its using RVM, but that doesn't seem to be an issue with cap as the stack trace above would suggest. The other fact of interest is that this server was first created with a custom script I wrote that downloads an archived version of the git repo and then manually runs what cap does on a deploy. The reason I'm doing this, if anyone asks, is for automation with AWS AutoScaling. If i do a normal deploy:setup (not using my AWS script), it works fine with deployments. But the gem list is the same, and the site works all the same either way. Its just something with the cap deploy
Any thoughts?
I figured out what I was doing wrong. on my custom AMI scripts, i was naming the initial release folder 'first' when it should be a timestamp the way capistrano normally names it. That screwed things up on subsequent deployments.

delayed job starts but does not process any jobs in production

I have a rails app using delayed job, it works fine in development.
However, when I pushed to production it doesn't do anything.
Delayed job starts up fine using either one of these commands:
RAILS_ENV=production rake jobs:work
or
RAILS_ENV=production script/delayed_job start
However, once the process has started it just sits there and does not process any of the jobs in the delayed_backend_mongoid table.
I checked the delayed_job.log and it shows that the process starts up fine but does not throw any errors.
And for the heck of it I checked the production.log and there are no errors there as well.
Also if I run
RAILS_ENV=production rake jobs:clear
It will delete the jobs that are in the que, so I don't think it has an issue communicating with mongodb.
I'm using
Rails 3.1.1
gem 'delayed_job'
gem 'delayed_job_mongoid'
Any insight will be greatly appreciated.
Ok so I finally got it to work, it wasn't related to delayed job at all. It had to do with the ruby gem Anemone. Anemone could not get proper authorization to the mongodb. Fixed, thanks anyways.

does Delayed_job daemon not run in development?

I'm using delayed_job and I am able to run jobs using rake jobs:work but using the daemonized version, it does nothing although I see it in the process list.
I'm using:
rails (3.0.9)
delayed_job (2.1.4)
daemons (1.0.10)
I'm running delayed_job using:
unix>RAILS_ENV=development script/delayed_job start
It could be a problem loading a custom job class file. To test that, try this:
Enter the rails console rails console --sandbox.
Make sure you have a job in the table job = Delayed::Job.first.
Try YAML.load(job.handler). If you get an error that looks like this: ArgumentError: undefined class/module MyCustomClass, it's probably a problem loading your custom job
Still in the rails console, run require 'My_Custom_Class. Then run the YAML.load(job.handler) command again. If this returns the appropriate object it's definitely a class loading problem.
To fix the problem create the file config/initializers/custom.rb and in it put require 'My_Custom_Class'.
You should then be able to run rake jobs::workoff and get something that looks like this:
[Worker(host:my.host pid:5085)] Starting job worker
[Worker(host:my.host pid:5085)] MyCustomJob completed after 0.0774
[Worker(host:my.host pid:5085)] 1 jobs processed at 9.1935 j/s, 0 failed ...
[Worker(host:my.host pid:5085)] No more jobs available. Exiting
To answer your question we may need more information.
Are jobs added to database? Are there any errors in jobs?
What's the result of RAILS_ENV=development script/delayed_job status as I already mentioned?
Second, did you went through the most common problems Wiki page?
https://github.com/collectiveidea/delayed_job/wiki/Common-problems