add some worker stuf

master
Thomas Riboulet 9 years ago
parent 79efb2a345
commit 2dd227e4f1

@ -1 +1,2 @@
web: bundle exec puma -t 5:5 -p ${PORT:-3000} -e ${RACK_ENV:-development}
sidekiq: bundle exec sidekiq -e ${RACK_ENV:-development}

@ -1,26 +1,28 @@
require 'sinatra'
require 'haml'
require 'sidekiq'
require './workers/test_job'
Sidekiq.configure_server do |config|
config.redis = { url: ENV['REDIS_URL'] || 'redis://localhost:6379/1', namespace: 'sidekiq' }
config.redis = { url: ENV['REDIS_URL'] || 'redis://localhost:6379/1' }
end
class MyRedis
def self.redis
@@redis ||= Redis.new(url: ENV['REDIS_URL'] || 'redis://localhost:6379/1' )
@@redis.set('blob', '200000000000000000000000')
@@redis.incr('blob1')
@@redis
end
def self.value
MyRedis.redis.get('blob')
MyRedis.redis.get('blob1')
end
end
class SimpleApp < Sinatra::Base
get '/' do
10.times { TestJob.perform_async }
haml "%h3 Hello THE BEANSTALK AWESOME World! #{MyRedis.value}"
end

@ -0,0 +1,7 @@
class TestJob
include Sidekiq::Worker
def perform
MyRedis.redis.incr('blob1')
end
end
Loading…
Cancel
Save