documentcloud / cloud-crowd

Parallel Processing for the Rest of Us

Home Page:https://github.com/documentcloud/cloud-crowd/wiki

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

NoMethodError - undefined method `cleanup' for #<CloudCrowd::AssetStore:0x...>

hchoroomi opened this issue · comments

Calling Job#destroy throws undefined method `cleanup' error. Seems autoload doesn't work for some reason.

crowd -c config/cloud_crowd/production -e production console
irb(main):001:0> Job.first.destroy
New RightAws::S3Interface using shared connections mode
Opening new HTTP connection to s3.amazonaws.com:80
=> #<CloudCrowd::Job id: 4254, status: 2, inputs: "[true]", action: "backup_database", 
options: "{}", outputs: "[true]", time: 54.545893, callback_url: nil, email: nil, created_at: 
"2010-06-03 05:00:03", updated_at: "2010-06-03 05:00:57">

Works fine for me. Can you provide a little more context to make it reproducible?

It works in crowd console. But when you try to access it externally it cannot load asset stores which of course is because it's not initialized correctly.

irb(main):002:0> require 'cloud-crowd'
irb(main):003:0> ActiveRecord::Base.establish_connection(...)
irb(main):004:0> CloudCrowd::Job.first
=> #<CloudCrowd::Job id: 1...
irb(main):005:0> CloudCrowd::Job.first.destroy
=> NoMethodError: undefined method...

Is there a way to configure CloudCrowd to work in this way? Setting asset store directly?

I'm sure you can always go and load the piece you need manually ... but there's probably a simpler way we can accomplish your goal.

If you're trying to clean up old jobs automatically, you can use a "201 Created" response code from your callback_url to signal that the job has been completed successfully, and may be removed.

If your jobs are more fire-and-forget, then you can use crowd cleanup, in conjunction with Cron, if you like.

Both are documented at the bottom of this page:

http://wiki.github.com/documentcloud/cloud-crowd/the-job-api