Rails Resque.enqueue user environment does not create jobs

I am using Resque for several asynchronous jobs. I created a custom integration environment that is a clone of my production environment. However, my Resque jobs are not added to Redis in my integration environment.

For example, if I run the following:

 $ RAILS_ENV=production rails console > Resque.enqueue(MyLovelyJob, 1) 

I will see that the task appears in resque-web.

But if I run the following:

 $ RAILS_ENV=integration rails console > Resque.enqueue(MyLovelyJob, 1) 

The job does not appear in resque-web.

It’s clear that I don’t have any configuration, I am pulling my hair out, trying to understand what it is.

0
source share
2 answers

a few expectations.

You have config/resque_config.rb or the like:

 require 'rubygems' require 'resque' # include resque so we can configure it require 'resque/server' require 'resque_scheduler' require 'resque_scheduler/server' require 'yaml' Resque.redis.namespace = "resque:api" rails_root = ENV['APP_ROOT'] || (File.dirname(__FILE__) + '/..') # require File.expand_path(File.join(rails_root,"lib","extensions","resque","worker.rb")) rails_env = RAILS_ENV if defined? RAILS_ENV rails_env ||= ( ENV['RAILS_ENV'] || 'development' ) resque_config = YAML.load_file(File.join(rails_root, 'config/resque.yml')) Resque.redis = resque_config[rails_env] # IN THIS ORDER Resque::Scheduler.dynamic = true Resque.schedule = YAML.load_file(File.join(rails_root, 'config/resque_schedule.yml')) # load the schedule 

and a config/resque.yml or similar:

 development: localhost:6379 test: localhost:6379 integration: localhost:6379 staging: localhost:6379 production: localhost:6379 

integration will either connect / interact with another server or use a different port. Then you must start its own Redis server so that 2 do not overlap. I suppose you didn’t want production and integration to queue for the same place?

+1
source

Here is what I did to fix the problem:

I created config/initializers/resque.rb with the following contents:

 rails_root = ENV['RAILS_ROOT'] || File.dirname(__FILE__) + '/../..' rails_env = ENV['RAILS_ENV'] || 'development' resque_config = YAML.load_file(rails_root + '/config/resque.yml') Resque.redis = resque_config[rails_env] 

I also created config/resque.yml with the following contents (obviously, they should be installed on everything that suits):

 development: localhost:6379 test: localhost:6379 integration: localhost:6379 staging: localhost:6379 production: localhost:6379 
0
source

Source: https://habr.com/ru/post/948071/


All Articles