summaryrefslogtreecommitdiff
path: root/util/empty-queue
blob: 3e5795b9883d826ab2c1aaefe556118a40f2dc5f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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