summaryrefslogtreecommitdiff
path: root/util/empty-queue
diff options
context:
space:
mode:
authorSteve Kemp <steve@steve.org.uk>2012-11-12 21:00:16 +0000
committerSteve Kemp <steve@steve.org.uk>2012-11-12 21:00:16 +0000
commit6334b9cdfc47bd85b2ce236572e08406324d25cd (patch)
treebd0bd3cc279d8377efde2affc8dc223bfb858ca2 /util/empty-queue
Initial dump of code.
Diffstat (limited to 'util/empty-queue')
-rwxr-xr-xutil/empty-queue23
1 files changed, 23 insertions, 0 deletions
diff --git a/util/empty-queue b/util/empty-queue
new file mode 100755
index 0000000..3e5795b
--- /dev/null
+++ b/util/empty-queue
@@ -0,0 +1,23 @@
+#!/usr/bin/ruby
+
+require 'beanstalk-client'
+
+
+beanstalk = Beanstalk::Pool.new(['localhost:11300'])
+
+#
+# Run until we're killed
+#
+while(true)
+ begin
+ puts "\n\nWaiting for job.."
+ job = beanstalk.reserve(1)
+ puts "Job acquired: #{Time.new.inspect}"
+ job.delete
+ rescue Beanstalk::TimedOut => ex
+ puts "Queue is empty"
+ exit(0)
+ end
+end
+
+