sweatshop 1.5.1 → 1.5.2

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -9,11 +9,11 @@ begin
9
9
  s.name = "sweatshop"
10
10
  s.summary = %Q{Sweatshop is a simple asynchronous worker queue build on top of rabbitmq/ampq}
11
11
  s.email = "amos@geni.com"
12
- s.homepage = "http://github.com/famoseagle/sweat-shop"
12
+ s.homepage = "http://github.com/famoseagle/sweatshop"
13
13
  s.description = "See summary"
14
14
  s.authors = ["Amos Elliston"]
15
15
  s.files = FileList["[A-Z]*", "install.rb", "{lib,test,config,script}/**/*"]
16
- s.add_dependency('famoseagle-carrot', '= 0.7.0')
16
+ s.add_dependency('carrot', '= 0.7.0')
17
17
  end
18
18
  Jeweler::GemcutterTasks.new
19
19
  rescue LoadError
data/VERSION.yml CHANGED
@@ -1,4 +1,5 @@
1
1
  ---
2
- :patch: 1
3
- :major: 1
2
+ :build:
4
3
  :minor: 5
4
+ :patch: 2
5
+ :major: 1
@@ -74,6 +74,8 @@ module MessageQueue
74
74
  if i == (@opts['cluster'].size-1)
75
75
  raise e
76
76
  else
77
+ Sweatshop.log "\n*** Sweatshop failing over to #{@opts['cluster'][i+1]} ***"
78
+ Sweatshop.log "Error: #{e.message}\n#{e.backtrace.join("\n")}"
77
79
  next
78
80
  end
79
81
  end
@@ -34,11 +34,14 @@ module Sweatshop
34
34
  end
35
35
 
36
36
  sig(:hup) do
37
- puts "Received HUP"
38
- Sweatshop.stop
39
- remove_pid!
40
- puts "Restarting sweatd with #{start_cmd}..."
41
- `#{start_cmd}`
37
+ begin
38
+ puts "Received HUP"
39
+ Sweatshop.stop
40
+ ensure
41
+ remove_pid!
42
+ puts "Restarting sweatd with #{start_cmd}..."
43
+ `#{start_cmd}`
44
+ end
42
45
  end
43
46
 
44
47
  before do
@@ -52,6 +55,8 @@ module Sweatshop
52
55
  daemonize(:kill_timeout => 20) do
53
56
  workers = []
54
57
 
58
+ Sweatshop.daemonize
59
+
55
60
  if groups.any?
56
61
  workers += Sweatshop.workers_in_group(groups)
57
62
  end
@@ -85,8 +85,12 @@ module Sweatshop
85
85
  end
86
86
  end
87
87
 
88
+ def self.queue=(queue)
89
+ @queue = queue
90
+ end
91
+
88
92
  def self.queue
89
- Sweatshop.queue(queue_group.to_s)
93
+ @queue ||= Sweatshop.queue(queue_group.to_s)
90
94
  end
91
95
 
92
96
  def self.workers
data/lib/sweatshop.rb CHANGED
@@ -79,6 +79,14 @@ module Sweatshop
79
79
  end
80
80
  end
81
81
 
82
+ def daemon?
83
+ @daemon
84
+ end
85
+
86
+ def daemonize
87
+ @daemon = true
88
+ end
89
+
82
90
  def stop
83
91
  @stop = true
84
92
  end
@@ -114,7 +122,7 @@ module Sweatshop
114
122
  end
115
123
 
116
124
  def queue_groups
117
- @queue_groups ||= workers.collect{|w| w.queue_group} << 'default'
125
+ @queue_groups ||= (workers.collect{|w| w.queue_group.to_s} << 'default').uniq
118
126
  end
119
127
 
120
128
  def pp_sizes
@@ -132,18 +140,18 @@ module Sweatshop
132
140
  next unless qconfig['cluster']
133
141
  servers << qconfig['cluster']
134
142
  end
135
- servers.flatten!
143
+ servers = servers.flatten.uniq
136
144
 
137
145
  servers.each do |server|
138
146
  puts "\nQueue sizes on #{server}"
139
147
  queue = MessageQueue::Rabbit.new('host' => server)
140
- queue_groups.each do |group|
141
- queues[group] = queue
148
+ workers.each do |worker|
149
+ worker.queue = queue
142
150
  end
143
151
  pp_sizes
144
152
  puts
145
153
  end
146
- @queues = {}
154
+ workers.each{|w| w.queue = nil}
147
155
  nil
148
156
  end
149
157
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sweatshop
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.1
4
+ version: 1.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Amos Elliston
@@ -9,11 +9,11 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-10-26 00:00:00 -07:00
12
+ date: 2010-01-03 00:00:00 -08:00
13
13
  default_executable: sweatd
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
- name: famoseagle-carrot
16
+ name: carrot
17
17
  type: :runtime
18
18
  version_requirement:
19
19
  version_requirements: !ruby/object:Gem::Requirement
@@ -57,7 +57,7 @@ files:
57
57
  - test/test_helper.rb
58
58
  - test/test_sweatshop.rb
59
59
  has_rdoc: true
60
- homepage: http://github.com/famoseagle/sweat-shop
60
+ homepage: http://github.com/famoseagle/sweatshop
61
61
  licenses: []
62
62
 
63
63
  post_install_message: