bluepill 0.0.46 → 0.0.47

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,53 +1,52 @@
1
+ # -*- encoding: utf-8 -*-
1
2
  module Bluepill
2
3
  module Triggers
3
4
  class Flapping < Bluepill::Trigger
4
5
  TRIGGER_STATES = [:starting, :restarting]
5
-
6
+
6
7
  PARAMS = [:times, :within, :retry_in]
7
-
8
+
8
9
  attr_accessor *PARAMS
9
10
  attr_reader :timeline
10
-
11
+
11
12
  def initialize(process, options = {})
12
13
  options.reverse_merge!(:times => 5, :within => 1, :retry_in => 5)
13
-
14
+
14
15
  options.each_pair do |name, val|
15
16
  instance_variable_set("@#{name}", val) if PARAMS.include?(name)
16
17
  end
17
-
18
+
18
19
  @timeline = Util::RotationalArray.new(@times)
19
20
  super
20
21
  end
21
-
22
+
22
23
  def notify(transition)
23
24
  if TRIGGER_STATES.include?(transition.to_name)
24
25
  self.timeline << Time.now.to_i
25
26
  self.check_flapping
26
27
  end
27
28
  end
28
-
29
+
29
30
  def reset!
30
31
  @timeline.clear
31
32
  super
32
33
  end
33
-
34
+
34
35
  def check_flapping
35
- num_occurances = (@timeline.nitems == self.times)
36
-
37
36
  # The process has not flapped if we haven't encountered enough incidents
38
- return unless num_occurances
37
+ return unless (@timeline.compact.length == self.times)
39
38
 
40
39
  # Check if the incident happend within the timeframe
41
40
  duration = (@timeline.last - @timeline.first) <= self.within
42
-
41
+
43
42
  if duration
44
43
  self.logger.info "Flapping detected: retrying in #{self.retry_in} seconds"
45
-
44
+
46
45
  self.schedule_event(:start, self.retry_in) unless self.retry_in == 0 # retry_in zero means "do not retry, ever"
47
46
  self.schedule_event(:unmonitor, 0)
48
47
 
49
48
  @timeline.clear
50
-
49
+
51
50
  # This will prevent a transition from happening in the process state_machine
52
51
  throw :halt
53
52
  end
@@ -1,72 +1,20 @@
1
+ # -*- encoding: utf-8 -*-
1
2
  module Bluepill
2
3
  module Util
3
- class RotationalArray < Array
4
- def initialize(size)
5
- super(size)
6
-
7
- @capacity = size
8
- @counter = 0
9
- end
10
-
11
- def push(value)
12
- idx = rotational_idx(@counter)
13
- self[idx] = value
14
-
15
- @counter += 1
16
- self
17
- end
18
-
19
- alias_method :<<, :push
20
-
21
- def pop
22
- raise "Cannot call pop on a rotational array"
23
- end
4
+ class RotationalArray < Array
5
+ def initialize(size)
6
+ @capacity = size
24
7
 
25
- def shift
26
- raise "Cannot call shift on a rotational array"
27
- end
8
+ super() # no size - intentionally
9
+ end
28
10
 
29
- def unshift
30
- raise "Cannot call unshift on a rotational array"
31
- end
32
-
33
- def last
34
- return if @counter.zero?
35
-
36
- self[rotational_idx(@counter - 1)]
37
- end
38
-
39
- def first
40
- return if @counter.zero?
41
- return self[0] if @counter <= @capacity
42
-
43
- self[rotational_idx(@counter)]
44
- end
45
-
46
- def clear
47
- @counter = 0
48
- super
49
- end
50
-
51
- def each(&block)
52
- times = @counter >= @capacity ? @capacity : @counter
53
- start = @counter >= @capacity ? rotational_idx(@counter) : 0
54
- times.times do |i|
55
- block.call(self[rotational_idx(start + i)])
56
- end
57
- end
11
+ def push(value)
12
+ super(value)
58
13
 
59
- unless method_defined?(:nitems)
60
- def nitems
61
- compact.length
62
- end
63
- end
64
-
65
- private
66
-
67
- def rotational_idx(idx)
68
- idx % @capacity
69
- end
70
- end
71
- end
14
+ self.shift if self.length > @capacity
15
+ self
16
+ end
17
+ alias_method :<<, :push
18
+ end
19
+ end
72
20
  end
@@ -1,3 +1,4 @@
1
+ # -*- encoding: utf-8 -*-
1
2
  module Bluepill
2
- VERSION = "0.0.46"
3
+ VERSION = "0.0.47"
3
4
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bluepill
3
3
  version: !ruby/object:Gem::Version
4
- hash: 67
5
- prerelease: false
4
+ hash: 65
5
+ prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 46
10
- version: 0.0.46
9
+ - 47
10
+ version: 0.0.47
11
11
  platform: ruby
12
12
  authors:
13
13
  - Arya Asemanfar
@@ -17,65 +17,49 @@ autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
19
 
20
- date: 2011-03-25 00:00:00 +03:00
21
- default_executable: bluepill
20
+ date: 2011-04-05 00:00:00 +04:00
21
+ default_executable:
22
22
  dependencies:
23
- - !ruby/object:Gem::Dependency
24
- name: i18n
25
- prerelease: false
26
- requirement: &id001 !ruby/object:Gem::Requirement
27
- none: false
28
- requirements:
29
- - - ">="
30
- - !ruby/object:Gem::Version
31
- hash: 11
32
- segments:
33
- - 0
34
- - 5
35
- - 0
36
- version: 0.5.0
37
- type: :runtime
38
- version_requirements: *id001
39
23
  - !ruby/object:Gem::Dependency
40
24
  name: daemons
41
25
  prerelease: false
42
- requirement: &id002 !ruby/object:Gem::Requirement
26
+ requirement: &id001 !ruby/object:Gem::Requirement
43
27
  none: false
44
28
  requirements:
45
- - - ">="
29
+ - - ~>
46
30
  - !ruby/object:Gem::Version
47
- hash: 5
31
+ hash: 19
48
32
  segments:
49
33
  - 1
34
+ - 1
50
35
  - 0
51
- - 9
52
- version: 1.0.9
36
+ version: 1.1.0
53
37
  type: :runtime
54
- version_requirements: *id002
38
+ version_requirements: *id001
55
39
  - !ruby/object:Gem::Dependency
56
40
  name: blankslate
57
41
  prerelease: false
58
- requirement: &id003 !ruby/object:Gem::Requirement
42
+ requirement: &id002 !ruby/object:Gem::Requirement
59
43
  none: false
60
44
  requirements:
61
- - - ">="
45
+ - - ~>
62
46
  - !ruby/object:Gem::Version
63
- hash: 107
47
+ hash: 105
64
48
  segments:
65
49
  - 2
66
50
  - 1
67
51
  - 2
68
- - 2
69
- version: 2.1.2.2
52
+ - 3
53
+ version: 2.1.2.3
70
54
  type: :runtime
71
- version_requirements: *id003
55
+ version_requirements: *id002
72
56
  - !ruby/object:Gem::Dependency
73
57
  name: state_machine
74
58
  prerelease: false
75
- requirement: &id004 !ruby/object:Gem::Requirement
59
+ requirement: &id003 !ruby/object:Gem::Requirement
76
60
  none: false
77
61
  requirements:
78
- - - ">="
62
+ - - ~>
79
63
  - !ruby/object:Gem::Version
80
64
  hash: 63
81
65
  segments:
@@ -92,14 +76,14 @@ dependencies:
92
76
  - 4
93
77
  version: 0.9.4
94
78
  type: :runtime
95
- version_requirements: *id004
79
+ version_requirements: *id003
96
80
  - !ruby/object:Gem::Dependency
97
81
  name: activesupport
98
82
  prerelease: false
99
- requirement: &id005 !ruby/object:Gem::Requirement
83
+ requirement: &id004 !ruby/object:Gem::Requirement
100
84
  none: false
101
85
  requirements:
102
- - - ">="
86
+ - - ~>
103
87
  - !ruby/object:Gem::Version
104
88
  hash: 11
105
89
  segments:
@@ -108,11 +92,30 @@ dependencies:
108
92
  - 4
109
93
  version: 2.3.4
110
94
  type: :runtime
95
+ version_requirements: *id004
96
+ - !ruby/object:Gem::Dependency
97
+ name: i18n
98
+ prerelease: false
99
+ requirement: &id005 !ruby/object:Gem::Requirement
100
+ none: false
101
+ requirements:
102
+ - - ~>
103
+ - !ruby/object:Gem::Version
104
+ hash: 11
105
+ segments:
106
+ - 0
107
+ - 5
108
+ - 0
109
+ version: 0.5.0
110
+ type: :runtime
111
111
  version_requirements: *id005
112
112
  description: Bluepill keeps your daemons up while taking up as little resources as possible. After all you probably want the resources of your server to be used by whatever daemons you are running rather than the thing that's supposed to make sure they are brought back up, should they die or misbehave.
113
- email: entombedvirus@gmail.com
113
+ email:
114
+ - entombedvirus@gmail.com
114
115
  executables:
115
116
  - bluepill
117
+ - bpsv
118
+ - sample_forking_server
116
119
  extensions: []
117
120
 
118
121
  extra_rdoc_files:
@@ -121,13 +124,16 @@ extra_rdoc_files:
121
124
  files:
122
125
  - .gitignore
123
126
  - DESIGN.md
127
+ - Gemfile
124
128
  - LICENSE
125
129
  - README.md
126
130
  - Rakefile
127
- - VERSION
128
131
  - bin/bluepill
129
132
  - bin/bpsv
133
+ - bin/sample_forking_server
130
134
  - bluepill.gemspec
135
+ - examples/example.rb
136
+ - examples/runit_example.rb
131
137
  - lib/bluepill.rb
132
138
  - lib/bluepill/application.rb
133
139
  - lib/bluepill/application/client.rb
@@ -135,6 +141,9 @@ files:
135
141
  - lib/bluepill/condition_watch.rb
136
142
  - lib/bluepill/controller.rb
137
143
  - lib/bluepill/dsl.rb
144
+ - lib/bluepill/dsl/app_proxy.rb
145
+ - lib/bluepill/dsl/process_factory.rb
146
+ - lib/bluepill/dsl/process_proxy.rb
138
147
  - lib/bluepill/group.rb
139
148
  - lib/bluepill/logger.rb
140
149
  - lib/bluepill/process.rb
@@ -151,15 +160,13 @@ files:
151
160
  - lib/bluepill/triggers/flapping.rb
152
161
  - lib/bluepill/util/rotational_array.rb
153
162
  - lib/bluepill/version.rb
154
- - lib/example.rb
155
- - lib/runit_example.rb
156
163
  has_rdoc: true
157
164
  homepage: http://github.com/arya/bluepill
158
165
  licenses: []
159
166
 
160
167
  post_install_message:
161
- rdoc_options:
162
- - --charset=UTF-8
168
+ rdoc_options: []
169
+
163
170
  require_paths:
164
171
  - lib
165
172
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -183,7 +190,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
183
190
  requirements: []
184
191
 
185
192
  rubyforge_project:
186
- rubygems_version: 1.3.7
193
+ rubygems_version: 1.5.2
187
194
  signing_key:
188
195
  specification_version: 3
189
196
  summary: A process monitor written in Ruby with stability and minimalism in mind.
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.0.46