resque | backed Ruby library for creating background jobs | Job Scheduling library
kandi X-RAY | resque Summary
kandi X-RAY | resque Summary
For the backstory, philosophy, and history of Resque’s beginnings, please see [the blog post] Resque allows you to create jobs and place them on a queue, then, later, pull those jobs off the queue and process them.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Executes the given block .
- Prune any of dead workers that have expired .
- Unregisters a worker .
- Performs a child process .
- Waits for the child process .
- Start the worker thread
- Waits for a single job
- Kills the child process .
- Reconnect to Redis .
- Attempt to find a job by name .
resque Key Features
resque Examples and Code Snippets
Community Discussions
Trending Discussions on resque
QUESTION
I have cloned an existing project and trying to run it in my system. Since this is the first time I don't have any Gemfile.lock file in my directory. I tried running bundle install and the following errors occur:
...ANSWER
Answered 2021-Apr-10 at 18:06In your project directory, try installing rails gem install rails -v 4.1.6
and removing the version from the failing gems like (liquid_markdown
, gon
, etc..) then try running bundle update
then bundle clean --force
I think this might be an issue because all the version of these gems are locked inside your Gemfile
QUESTION
I've been trying to fix this for about two days but I'm getting no where. I'm trying to get the resque-web page to show but I keep running into the error
Sprockets::Rails::Helper::AssetNotPrecompiled in ResqueWeb::Overview#show
Message shown
...ANSWER
Answered 2021-Mar-20 at 07:29resque comes with a built-in server. You do not need resque-web
and it seems it is not maintained (last commit was on 2018).
Let's try this:
QUESTION
I was following the Action Mailer guideon https://guides.rubyonrails.org/action_mailer_basics.html#calling-the-mailer
I did almost the same of what tutorial show. The controller:
...ANSWER
Answered 2021-Mar-16 at 20:38It's not working because ActiveJob doesn't support the objects. To make it accessible you have to either convert it into json string and then deserialise in the mailer method.
Try sending the object as json string and retrieve the id value, then use:
QUESTION
In my Rails application users can cancel their subscription which should trigger a function that downgrades their account at their current_billing_period_end
(this variable is provided by the API of the payment provider). For example a user cancels their subscription on the 12th of April but has a valid subscription until the 1st of March. So the premium
entry in the database for this user should be set to false
only on the 1st of March.
I have implemented a working solution with Resque and Resque-Scheduler but am now wondering if that might be a bit overkill?
I could instead set a subscription_end_date
database entry for the user when the subscription is canceld and set it to current_billing_period_end
and then whenever the user authenticates I'd run
ANSWER
Answered 2021-Feb-23 at 18:48Don't do that.
It's a bad design to schedule many jobs for a few days or weeks later, especially when they perform a critical task.
Why?
Mainly because the scheduled job's date is not stored in your application database but another one, most of the time in Redis. In the majority of cases, it is not included in the backup. So the day you need to restore a backup, you'll lose all pending scheduled job. All the accounts that were pending for the last subscription period to end may remain open.
The safest solution is to rely on a database field holding the actual end of the subscription date. Let's name it subscription_ends_on
. If your user unsubscribes on April 12th, you set subscription_ends_on
with the value "March 1rst".
Then you create a background job that runs every day at midnight and unsubscribe all accounts where subscription_ends_on
is not null and is less than or equal to today.
QUESTION
My app works locally, however when I try to deploy to Heroku, I get a Sprockets::FileNotFound: couldn't find file 'angular' with type 'application/javascript'
error.
I have tried precompiling with RAILS_ENV=production bundle exec rake assets:precompile
and purging my build cache with heroku builds:cache:purge -a findum
, but still no luck. I recently migrated from Bower to Yarn– not sure if my asset path is the problem?
Has anyone run into a similar error that they were able to resolve? So many thanks 🙏.
This is my application.js
:
ANSWER
Answered 2021-Feb-19 at 13:57Update:
It looks like it was a problem with my post-Bower configuration (I migrated from Bower --> Yarn) I was able to solve Sprockets errors by adding this line to my assets.rb
:
Rails.application.config.assets.paths << Rails.root.join('node_modules')
and by running yarn add
for files that Sprockets could not locate.
I also made the following updates to old package names in my `application.rb'
QUESTION
I added a new gem to my Gemfile
unrelated to the resque
gem and I've having issues with bundle install
. I do not want to run bundle update because I don't wan't to make unnecessary changes within the Gemfile.lock
. What is the best way to get past this error without making too many changes? I want to keep my resque versions consistent with previous versions.
ANSWER
Answered 2020-Dec-12 at 22:50The problem with resque-status
: its last commit (to date, for 0.5.0 version) was done 5 years ago, so is a pretty outdated and unmaintained gem.
As long as this isn't updated, you should try luck with some of the forks. This looks promising, as it update the version restrictions in the gemspec, so try adding to your Gemfile
:
QUESTION
I have the following problem with Resque and Rails 6 (ruby 2.7.2). I am new to this gem and wanted to do some simple testing to see how things are handled, so I created a simple failing job:
...ANSWER
Answered 2020-Dec-11 at 12:01I don't know why, but this is the solution. Rather than running:
QUESTION
My application has multiple queues and I'm trying to prioritize specific queues.
resque-pool.yml
...ANSWER
Answered 2020-Oct-23 at 16:38You have it right. As the main Resque documentation states:
Resque doesn't support numeric priorities but instead uses the order of queues you give it. We call this list of queues the "queue list."
Let's say we add a warm_cache queue in addition to our file_serve queue. We'd now start a worker like so:
$ QUEUES=file_serve,warm_cache rake resque:work
When the worker looks for new jobs, it will first check file_serve. If it finds a job, it'll process it then check file_serve again. It will keep checking file_serve until no more jobs are available. At that point, it will check warm_cache. If it finds a job it'll process it then check file_serve (repeating the whole process).
In this way you can prioritize certain queues.
Note that, in a resque-pool setup, each process that spawns will follow its own priority (so in the example config it's possible bar
jobs will get processed before foo
jobs if the process that only processes bar
is free while the others are busy). That's a feature, though, not a bug!
As for how you can test it, simply enqueue a bunch of jobs in each queue and watch as they get processed in resque-web (or the logs).
QUESTION
is there a way to automatically delete posts/products/articles or anything created on a rails 6 app? I'm trying to build an online image repository that users can upload images that appear only for 24 hours and then get deleted.I have the posting and saving of the pictures/text through active storage and Postgres but i can't get it to get deleted automatically. I've read about whenever sidekiq and resque scheduler but i find it difficult to understand and make it work. i tried from some tutorials and reading the documentation but I'm still having trouble. Can anyone point me in the right direction or try to help me?
...ANSWER
Answered 2020-Aug-15 at 20:44You have many options
The simplest one is creating a rake task and setting up a cron job to call this time every minute or something like that. If you call it every 24h you may end up with posts staying for up to 47h.
You can use delayed jobs in two ways
2.1 In an after_create callback, set a job to delete the post after 24 hours. Something like this
handle_asynchronously :in_the_future, run_at: Proc.new { 24.hours.from_now }
2.2 Using delayed_job_recurring gem to do the same thing in option one, but without the need of using cron
Edit: I would use option 2.1 since it's the simplest one and easier to maintain, the only downside is that it will create a job for every post, but that shouldn't be a problem even with a million posts a day
QUESTION
On Ruby on Rails I need to start a 'rescue' task.
To let this work the command QUEUE=* rake resque:work
must be executed in a new terminal (macOS).
But: Can someone explain what this actually means?
...ANSWER
Answered 2020-Jul-29 at 09:18resque worker will keep on polls redis queues for pending jobs. So, we need to pass queue names as args to resque task while starting the task. QUEUE=*
is doing the same here.
So, here your question can be breakdown to 2 parts,
- what is the purpose of
QUEUE
- What is the purpose of
*
QUEUE
:
In ruby we can do this in 4 ways.
Rake args:
rake resque:work[*]
For this to work resque task should have the following convention
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install resque
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page