summaryrefslogtreecommitdiff
path: root/queue/list/run.rb
diff options
context:
space:
mode:
authorSteve Kemp <steve@steve.org.uk>2015-12-18 15:44:24 +0200
committerSteve Kemp <steve@steve.org.uk>2015-12-18 15:44:24 +0200
commit43d6c5affc78755f8a45b242d8d39acc72bd3526 (patch)
treec09ad3fc849d662f914286e48d5ff64b7b18cbca /queue/list/run.rb
parent55ca438b2db24eadd2a5008f6f9d13fcf25a30fa (diff)
Document queue
Diffstat (limited to 'queue/list/run.rb')
-rwxr-xr-xqueue/list/run.rb32
1 files changed, 32 insertions, 0 deletions
diff --git a/queue/list/run.rb b/queue/list/run.rb
new file mode 100755
index 0000000..08623b0
--- /dev/null
+++ b/queue/list/run.rb
@@ -0,0 +1,32 @@
+#!/usr/bin/ruby
+
+require "redis"
+require 'pp'
+@redis = Redis.new(:host => "127.0.0.1")
+
+
+
+def fetch(timeout = 1)
+ job = nil
+
+ loop do
+ job = @redis.lpop('list')
+
+ if !job.nil?
+ return job
+ else
+ sleep(timeout)
+ end
+
+ end
+end
+
+
+
+while( x = fetch() )
+ puts "Got job : #{x}"
+ if ( x =~ /ping/i )
+ puts "PING TEST - sleeping"
+ sleep 5
+ end
+end