rcarvalho-workless 1.0.2.5 → 1.0.2.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -11,11 +11,13 @@ module Delayed
11
11
  def self.up
12
12
  nw = self.calculate_num_workers
13
13
  client.set_workers(ENV['APP_NAME'], nw) if nw
14
+ rescue
14
15
  end
15
16
 
16
17
  def self.down
17
18
  nw = self.calculate_num_workers
18
19
  client.set_workers(ENV['APP_NAME'], nw) unless self.workers == 0 or self.jobs.count > 0
20
+ rescue
19
21
  end
20
22
 
21
23
  def self.workers
@@ -10,16 +10,28 @@ module Delayed
10
10
 
11
11
  def self.up
12
12
  nw = self.calculate_num_workers
13
- client.ps_scale(ENV['APP_NAME'], :type => 'worker', :qty => nw) if nw
13
+ if nw
14
+ if @@current_num_workers != nw
15
+ @@current_num_workers = nw
16
+ client.ps_scale(ENV['APP_NAME'], :type => 'worker', :qty => @@current_num_workers)
17
+ end
18
+ end
19
+ rescue
14
20
  end
15
21
 
16
22
  def self.down
17
23
  nw = self.calculate_num_workers
18
- client.ps_scale(ENV['APP_NAME'], :type => 'worker', :qty => nw) unless self.workers == 0 or self.jobs.count > 0
24
+ if nw
25
+ if @@current_num_workers != nw
26
+ @@current_num_workers = nw
27
+ client.ps_scale(ENV['APP_NAME'], :type => 'worker', :qty => nw)
28
+ end
29
+ end
30
+ rescue
19
31
  end
20
32
 
21
33
  def self.workers
22
- client.ps(ENV['APP_NAME']).count { |p| p["process"] =~ /worker\.\d?/ }
34
+ @@current_num_workers || client.ps(ENV['APP_NAME']).count { |p| p["process"] =~ /worker\.\d?/ }
23
35
  end
24
36
 
25
37
  end
metadata CHANGED
@@ -6,8 +6,8 @@ version: !ruby/object:Gem::Version
6
6
  - 1
7
7
  - 0
8
8
  - 2
9
- - 5
10
- version: 1.0.2.5
9
+ - 7
10
+ version: 1.0.2.7
11
11
  platform: ruby
12
12
  authors:
13
13
  - lostboy