deputy 0.1.42 → 0.1.43

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Readme.md CHANGED
@@ -8,6 +8,9 @@ Use with [sheriff](http://github.com/dawanda/sheriff).
8
8
 
9
9
  Put sheriff url into `~/.deputy.yml`
10
10
  sheriff_url: http://sheriff.mydomain.com
11
+ # Optional
12
+ max_random_start_delay: 30
13
+ timeout: 10
11
14
 
12
15
  Add deputy to cron with deputy --install-cron (logs to /tmp/deputy.log)
13
16
 
@@ -15,4 +18,5 @@ Usage
15
18
  #####
16
19
 
17
20
  ### Report something
18
- deputy Cronjob.ran 1
21
+ deputy Cronjob.ran
22
+ deputy Cronjob.users_found 123
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.42
1
+ 0.1.43
data/deputy.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{deputy}
8
- s.version = "0.1.42"
8
+ s.version = "0.1.43"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Michael Grosser"]
12
- s.date = %q{2010-07-29}
12
+ s.date = %q{2010-08-03}
13
13
  s.default_executable = %q{deputy}
14
14
  s.email = %q{mirko@dawanda.com}
15
15
  s.executables = ["deputy"]
data/lib/deputy.rb CHANGED
@@ -100,6 +100,8 @@ module Deputy
100
100
  end
101
101
 
102
102
  def self.run_plugins
103
+ sleep_random_interval
104
+
103
105
  content = get("/plugins.rb")
104
106
 
105
107
  Scout.plugins(content).each do |interval, plugin|
@@ -147,6 +149,20 @@ module Deputy
147
149
  raise "No deputy.yml found in /etc or #{home}"
148
150
  end
149
151
 
152
+ def self.sleep_random_interval
153
+ if max = config['max_random_start_delay']
154
+ constant_number = Socket.gethostname.sum{|x| x[0]}
155
+ sleep seeded_random(max, constant_number)
156
+ end
157
+ end
158
+
159
+ def self.seeded_random(max_rand, seed)
160
+ old = srand(seed)
161
+ result = rand(max_rand)
162
+ srand(old)
163
+ result
164
+ end
165
+
150
166
  # stolen from klarlack -- http://github.com/schoefmax/klarlack
151
167
  # to get an reliable timeout that wont fail on other platforms
152
168
  # or if sytem_timer is missing
data/spec/deputy_spec.rb CHANGED
@@ -156,6 +156,16 @@ describe Deputy do
156
156
  Deputy.run_plugins
157
157
  $notify.should == 1
158
158
  end
159
+
160
+ it "sleeps a random interval if given in config" do
161
+ Socket.stub!(:gethostname).and_return 'foo'
162
+ Deputy.stub!(:config).and_return('max_random_start_delay' => 30)
163
+ Deputy.stub!(:send_report)
164
+ Deputy.should_receive(:sleep).with(25).and_raise("OK")
165
+ lambda{
166
+ Deputy.run_plugins
167
+ }.should raise_error("OK")
168
+ end
159
169
  end
160
170
 
161
171
  describe :send_report do
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 42
9
- version: 0.1.42
8
+ - 43
9
+ version: 0.1.43
10
10
  platform: ruby
11
11
  authors:
12
12
  - Michael Grosser
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-07-29 00:00:00 +02:00
17
+ date: 2010-08-03 00:00:00 +02:00
18
18
  default_executable: deputy
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency