0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Minimal steps to get Rails | resque-scheduler

Last updated at Posted at 2019-04-16

1. Add a gem

In the familiar Gemfile. Install the resque body and the resque-scheduler.

 gem 'resque' gem 'resque-scheduler' 

 $ bundle install 

2. Write the processing content to the model

Write the processing you want the worker to finally execute in the perform method of the model. Here, as a test, create a process that only produces standard output.

 class Example @queue = :default def self.perform p 'Hello Sword!' end end 

3. Add settings for workers

You only need to add two lines to the Rakefile.

 require 'resque/tasks' require 'resque/scheduler/tasks' 

4. Start up the resque worker

First of all, start the worker of resque itself. (not resque-scheduler's)

$ TERM_CHILD=1 QUEUES=* bundle exec rake environment resque:work

It will be in the following state.

image

Let's leave this and move on to the next.

5. Launch the resque-scheduler worker

It is necessary to launch separately from the worker of the resque body. So run in another window

$ bundle exec rake resque:scheduler

It will be in the following state.

image

6. Register a job

In addition, let's add a job in a separate window from the two workers. In other words, three windows are used.

It's easy to use the Rails console.

$ bundle exec rails console

 irb(main)> Resque.enqueue_in(5.second, Example) => true 

By the way, this means "register the job 5 seconds from now".

6. The job is run

After a while, let's look at the worker of the main body of resque, which was launched in step 1. You will see that the job "standard output string" is being executed.

image

Congrats!

environment

  • resque-scheduler (4.0.0)
  • resque (1.25.2)
  • Rails 4.2.4

Original by

Rails | resque-scheduler を動かす最小手順

About

About this translattion

チャットメンバー募集

何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

Twitter

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?