blob: 006316946ba572d7273b9295cb9be8e93c573ee7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
require 'rack'
require 'puma'
require 'rack/handler/puma'
require 'redis'
class Application
attr_reader :redis
def initialize
@redis = Redis.new
end
def call(env)
if env['rack.hijack?']
env['rack.hijack'].call
io = env['rack.hijack_io']
redis.subscribe("ruby") do |on|
on.message do |channel, message|
puts message.inspect
io.write(message)
end
end
#Thread.new do
#loop do
#sleep 5
#io.write("I'm awake...")
#end
#end
else
['200', {'Content-Type' => 'text/html'}, ['A barebones rack app.']]
end
end
end
Rack::Handler::Puma.run Application.new
|