stalker 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/VERSION +1 -1
  2. data/lib/stalker.rb +17 -3
  3. metadata +3 -3
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.1
1
+ 0.2.2
data/lib/stalker.rb CHANGED
@@ -35,6 +35,8 @@ module Stalker
35
35
  loop do
36
36
  work_one_job
37
37
  end
38
+ rescue Beanstalk::NotConnected => e
39
+ failed_connection(e)
38
40
  end
39
41
 
40
42
  def work_one_job
@@ -46,9 +48,21 @@ module Stalker
46
48
  handler.call(args)
47
49
  job.delete
48
50
  log_job_end(name)
51
+ rescue Beanstalk::NotConnected => e
52
+ failed_connection(e)
53
+ rescue SystemExit
54
+ raise
49
55
  rescue => e
50
56
  STDERR.puts exception_message(e)
51
- job.bury
57
+ job.bury rescue nil
58
+ log_job_end(name, 'failed')
59
+ end
60
+
61
+ def failed_connection(e)
62
+ STDERR.puts exception_message(e)
63
+ STDERR.puts "*** Failed connection to #{beanstalk_url}"
64
+ STDERR.puts "*** Check that beanstalkd is running (or set a different BEANSTALK_URL)"
65
+ exit 1
52
66
  end
53
67
 
54
68
  def log_job_begin(name, args)
@@ -64,10 +78,10 @@ module Stalker
64
78
  @job_begun = Time.now
65
79
  end
66
80
 
67
- def log_job_end(name)
81
+ def log_job_end(name, type="finished")
68
82
  ellapsed = Time.now - @job_begun
69
83
  ms = (ellapsed.to_f * 1000).to_i
70
- log "-> #{name} finished in #{ms}ms"
84
+ log "-> #{name} #{type} in #{ms}ms"
71
85
  end
72
86
 
73
87
  def log(msg)
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 2
8
- - 1
9
- version: 0.2.1
8
+ - 2
9
+ version: 0.2.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Adam Wiggins
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-05-13 00:00:00 -07:00
17
+ date: 2010-05-18 00:00:00 -07:00
18
18
  default_executable: stalk
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency