복붙노트

[REDIS] sidekiq가 작업을 처리하지 않고, 작업이 대기열에 갇혀

REDIS

sidekiq가 작업을 처리하지 않고, 작업이 대기열에 갇혀

나는 트위터 스트림 API를, sidekiq, 유니콘과시나와 함께 작동하는 간단한 응용 프로그램이 있습니다. 모든 작업이 전혀 처리되지 않는 대신 ... 잘 작동합니다. 그들은하여 대기열에 갇혀 (그리고 나는 sidekiq 웹 UI에서 알고)된다.

이건 내 코드입니다 :

Procfile :

sidekiq: bundle exec sidekiq -C config/sidekiq.yml -e development -r ./lib/tweet_streamer.rb
unicorn: bundle exec unicorn -c config/unicorn.rb
redis: redis-stable/src/redis-server

설정 / unicorn.rb :

listen 5000, :tcp_nopush => true
timeout 30
preload_app true
GC.respond_to?(:copy_on_write_friendly=) and
  GC.copy_on_write_friendly = true

before_fork do |server, worker|
end

after_fork do |server, worker|
end

tweet_streamer.rb :

require_relative "../config/tweetstream"
require_relative "workers"

class TweetStreamer

  client = TweetStream::Client.new
  client.on_enhance_your_calm do |s|
    puts "on_enhance_your_calm #{s}"
  end

  puts "onstream"

  client.userstream do |status|
    ##
    ## TODO: Some kind of log
    ##
    puts "start process"
    # TweetStatusWorker.perform_async(status.to_hash)
    Sidekiq::Client.push('class' => TweetStatusWorker, 'args' => ["a"])
    puts "process started!"
  end

end

workers.rb

require_relative "../config/sidekiq"
require_relative 'workers/tweet_status_worker'

는 config / sidekiq.rb :

require 'sidekiq'

Sidekiq.configure_client do |config|
  config.redis = { :size => 1 }
end

Sidekiq.configure_server do |config|
  config.redis = { :size => 6 }
end

작업자 :

class TweetStatusWorker
  include Sidekiq::Worker
  def perform(status)
    logger.warn "I'm working on it!"
  end
end

내 sidekiq.yml :

 ---
:pidfile: tmp/pids/sidekiq.pid
development:
  :verbose: true
  :logfile: log/sidekiq_development.log

내 config.ru :

require "rubygems"
require "sinatra"

Bundler.require

require File.expand_path '../twitter_module.rb', __FILE__

require 'sidekiq/web'

run Rack::URLMap.new('/' => TwitterModule, '/sidekiq' => Sidekiq::Web)

내 애플 클래스 :

require 'sinatra/base'

class TwitterModule < Sinatra::Base
end

이것은 내가 응용 프로그램을 시작하고 나는 트윗을하는 과정을 시작하기위한 모든 괜찮을 것 같다 때 내가받은 로그입니다 ..

17:36:31 sidekiq.1 | started with pid 65599
17:36:31 unicorn.1 | started with pid 65600
17:36:31 redis.1   | started with pid 65601
17:36:31 redis.1   | [65601] 14 Oct 17:36:31.717 # Warning: no config file specified, using the default config. In order to specify a config file use redis-stable/src/redis-server /path/to/redis.conf
17:36:31 redis.1   | [65601] 14 Oct 17:36:31.718 * Max number of open files set to 10032
17:36:31 redis.1   |                 _._                                                  
17:36:31 redis.1   |            _.-``__ ''-._                                             
17:36:31 redis.1   |       _.-``    `.  `_.  ''-._           Redis 2.6.16 (f132ada8/1) 64 bit
17:36:31 redis.1   |   .-`` .-```.  ```\/    _.,_ ''-._                                   
17:36:31 redis.1   |  (    '      ,       .-`  | `,    )     Running in stand alone mode
17:36:31 redis.1   |  |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
17:36:31 redis.1   |  |    `-._   `._    /     _.-'    |     PID: 65601
17:36:31 redis.1   |   `-._    `-._  `-./  _.-'    _.-'                                   
17:36:31 redis.1   |  |`-._`-._    `-.__.-'    _.-'_.-'|                                  
17:36:31 redis.1   |  |    `-._`-._        _.-'_.-'    |           http://redis.io        
17:36:31 redis.1   |   `-._    `-._`-.__.-'_.-'    _.-'                                   
17:36:31 redis.1   |  |`-._`-._    `-.__.-'    _.-'_.-'|                                  
17:36:31 redis.1   |  |    `-._`-._        _.-'_.-'    |                                  
17:36:31 redis.1   |   `-._    `-._`-.__.-'_.-'    _.-'                                   
17:36:31 redis.1   |       `-._    `-.__.-'    _.-'                                       
17:36:31 redis.1   |           `-._        _.-'                                           
17:36:31 redis.1   |               `-.__.-'                                               
17:36:31 redis.1   | 
17:36:31 redis.1   | [65601] 14 Oct 17:36:31.719 # Server started, Redis version 2.6.16
17:36:31 redis.1   | [65601] 14 Oct 17:36:31.728 * DB loaded from disk: 0.010 seconds
17:36:31 redis.1   | [65601] 14 Oct 17:36:31.728 * The server is now ready to accept connections on port 6379
17:36:33 unicorn.1 | I, [2013-10-14T17:36:33.208428 #65600]  INFO -- : Refreshing Gem list
17:36:33 unicorn.1 | I, [2013-10-14T17:36:33.813454 #65600]  INFO -- : listening on addr=0.0.0.0:5000 fd=9
17:36:33 unicorn.1 | I, [2013-10-14T17:36:33.814790 #65600]  INFO -- : master process ready
17:36:33 unicorn.1 | I, [2013-10-14T17:36:33.816138 #65607]  INFO -- : worker=0 ready
17:36:33 sidekiq.1 | onstream
17:36:43 sidekiq.1 | start process
17:36:43 sidekiq.1 | process started!

분명히 sidekiq 로그에 아무것도 :

2013-10-14T16:36:43Z 65599 TID-ouo5je95k INFO: Booting Sidekiq 2.15.1 using redis://localhost:6379/0 with options {:size=>6}
2013-10-14T16:37:32Z 65599 TID-ouo5je95k DEBUG: Terminating 4 actors...

최신 정보:

좋아, 나는 그것을 발견했다. 트리머 문제입니다. 내가 트리머 블록의 작업 외부를 실행하는 경우, 이것은 잘 작동합니다. 왜 APPEND이며 어떻게 그것을 해결할 수에 대한 어떤 아이디어?

해결법

    from https://stackoverflow.com/questions/19364978/sidekiq-does-not-process-jobs-jobs-stuck-in-enqueue by cc-by-sa and MIT license