summaryrefslogtreecommitdiff
path: root/util/empty-queue
diff options
context:
space:
mode:
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
+
+