delayed-job

Repeatable job for Laravel json api

廉价感情. 提交于 2019-12-08 07:33:12
问题 I am writing Laravel json API on MySQL. Imagine user creates record inside my database. What I want to do is perform some kind of operation 24 hours after this record is created. I can achieve this using : AfterInsertJob::dispatch()->delay(now()->addHours(24)); . But I need to perform this operation again and again until record exists. So how can I do that? Should I dispatch job inside job? I mean Should I dispatch AfterInsertJob inside AfterInsertJob ? I could use Schedule but then how to

Requeue or evaluate delayed job from inside?

狂风中的少年 提交于 2019-12-08 04:11:18
问题 Is there a way to determine the status of a running delayed_job job from inside the job task itself? I have a job that interacts with a service that can be pretty flaky and for a certain class of connection failures I'd like to requeue the job and only raise an exception if a connection failure occurs again at the retry limit. Pseudo-code to demonstrate what I want to be able to do: def do_thing service.send_stuff(args) rescue Exception1, Exception2 if job.retries == JOBS_MAX raise else job

How to perform a background job now?

拥有回忆 提交于 2019-12-08 04:07:44
问题 I want to execute this on background Product.all.map { |product| product.save } When I save the product will call a callback to create a new record in a table with the costs of products I create a job for this, but if I execute perform_now it is not executed on background and perform_later executes long after. I want to execute this right now but in background. I'm not sure if I can just execute this in a thread too. I am using Delayed Job, here is the job class UpdateProductCostsJob <

Rails server hangs when started with foreman

天大地大妈咪最大 提交于 2019-12-08 03:56:54
问题 Here's what my Procfile looks like: web: bundle exec rails server thin -p $PORT -e $RACK_ENV worker: bundle exec rake jobs:work I intend to add a worker process because I wish to run some background jobs. I'm following these instructions This is what I noticed: No problems encountered if the worker is started separately. When I keep the second line in the Procfile and don't not change anything else, the rails server serves a couple of requests and hangs after that As mentioned here , I've

Net::SSH works from production rails console, AuthenticationFailed from production webapp

坚强是说给别人听的谎言 提交于 2019-12-07 22:23:30
问题 I have a rails app where a user can submit a form and it goes off and connects to a remote server via ssh to call a script. Eventually I plan to use delayed_job or something like that but I can't get it to work in production with even a simple test. The odd thing is, Net::SSH works just fine from the console in production, but it fails with AuthenticationFailed when I submit the form in production. Both the console and the webapp work fine in development. The error: Net::SSH:

Rails 3: Return large amount of data to user via API

此生再无相见时 提交于 2019-12-07 21:13:31
问题 My app has an API that users can request data. Sometimes that data takes time to process and is breaking my code. I need a solution for this and I was thinking in using delayed_job but I'm not sure how this works. If the user makes a request, I need to give him an answer. Even if I process the data in background, the call still needs to wait until the job returns. What is the solution for this? I am not sure how to do it. Thanks 回答1: Heroku has a 30 second timeout, which is why your requests

Upgrading to Rails 3.2.2: How to solve the 'undefined method for Syck::DomainType' error related to the Delayed Job gem?

孤街浪徒 提交于 2019-12-07 18:05:04
问题 I am running Ruby on Rails 3.2.2 from 3.1.0. I have the issue undefined method send_register_email\' for #<Syck::DomainType:0x0000012d2346b8>\n/<ABSOLUTE_PATH>/.rvm/gems/ruby-1.9.2-p290/gems/delayed_job-3.0.1/lib/delayed/performable_mailer.rb:6:in perform ... with the DelayedJob gem that many other people have tried to solve: someone made successfully that, others no. I am in the latter category, also if I tried all solutions I've found on the Web. At this time, in my Gemfile I have: gem

rake jobs:work error, uninitialized constant

孤者浪人 提交于 2019-12-07 16:07:16
问题 i am using delayed_job 2.1.0.pre2, and in my lib i have a class which named MailingJob(mailing_job.rb),and it has one method named perform. In my controller , i put a new MailingJob object in my delayed_job queue as the doc said. but when i run the "rake jobs:work" command,it always told me that it can't find "MailingJob", is it necessary to require the mailing_job.rb file?if yes,where should i put this? thanks! 回答1: mailing_job.rb must be in a place where Rails can find and auto-load it.

Delayed job with custom attributes

﹥>﹥吖頭↗ 提交于 2019-12-07 15:22:27
问题 I'm using delayed job 3.0.2 with ActiveRecord and Rails 3.2.3. I have a User model which uses the has_secure_password mixin, so the password is only stored encrypted. Now I want to use delayed job to send the welcome email, which should contain a copy of the unencrypted password. When creating the record, the plain-text password is in User#password. But delayed job seems to serialize/ deserialize the id of the record only and create a new instance of the model by doing User.find(X). This way

delayed_job: 'undefined method' error when using handle_asynchronously

有些话、适合烂在心里 提交于 2019-12-07 14:21:31
问题 I'm attempting to use delayed_job to run a larger csv import into my rails database. Here are my controller and model methods: controller method def import InventoryItem.import(params[:file], params[:store_id]) redirect_to vendors_dashboard_path, notice: "Inventory Imported." end model method def self.import(file, store_id) CSV.foreach(file.path, headers: true) do |row| inventory_item = InventoryItem.find_or_initialize_by_upc_and_store_id(row[0], store_id) inventory_item.update_attributes(