我可以使用perform_later
将作业排入队列,但它根本没有出列。
我也设置WelcomeEmailJob.set(wait: 1.seconds)
它没有启动。
tail -f log/development.log
[ActiveJob] Enqueued WelcomeEmailJob (Job ID: 7df3d8a5-8eaa-4cbe-b419-83f0326b5376) to Sidekiq(default)
[ActiveJob] Enqueued WelcomeEmailJob (Job ID: 29100edd-9896-4acb-b16b-4695e7be5757) to Sidekiq(default)
[ActiveJob] Enqueued WelcomeEmailJob (Job ID: fa57ef26-7134-442a-9bde-858fa487f5d4) to Sidekiq(default)
[ActiveJob] Enqueued WelcomeEmailJob (Job ID: d645e315-28ad-43ce-9426-e4a338d52bdc) to Sidekiq(default)
[ActiveJob] Enqueued WelcomeEmailJob (Job ID: 12b89c71-96c6-4ad5-a655-f0d301d10543) to Sidekiq(default)
[ActiveJob] Enqueued WelcomeEmailJob (Job ID: f9d60fd0-9633-4b65-80f8-c0d5bdbc473b) to Sidekiq(default)
[ActiveJob] Enqueued WelcomeEmailJob (Job ID: 4385647c-bfc2-425e-894f-000d0ccb2095) to Sidekiq(default)
[ActiveJob] Enqueued WelcomeEmailJob (Job ID: 87624fe0-44ea-4eb9-a97e-fcada60a9354) to Sidekiq(default)
我应该如何将工作列入队列并查看列表?
class WelcomeEmailJob < ActiveJob::Base
queue_as :default
def perform
# Do something later
logger.warn "TEST WARNING"
end
end
docker-compose.rb
services:
web:
depends_on:
- 'postgres'
- 'redis'
build: .
command: rails server -b 0.0.0.0
ports:
- '3000:3000'
volumes:
- '.:/usr/src/app'
env_file:
- '.env'
postgres:
image: 'postgres:9.4.4'
environment:
POSTGRES_USER: 'postgres'
ports:
- '5432:5432'
redis:
image: 'redis:3.2-alpine'
command: redis-server --requirepass yourpassword
ports:
- '6379:6379'
sidekiq:
depends_on:
- 'postgres'
- 'redis'
build: .
command: bundle exec sidekiq -C config/sidekiq.yml.erb
volumes:
- '.:/usr/src/app'
env_file:
- '.env'
config/initializers/sidekiq.rb
sidekiq_config = { url: 'redis://127.0.0.1:6379' }
Sidekiq.configure_server do |config|
config.redis = sidekiq_config
end
Sidekiq.configure_client do |config|
config.redis = sidekiq_config
end
答案 0 :(得分:0)
你应该运行sidekiq工作者。
bundle exec sidekiq