evented_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,57 +1,55 @@
1
+ # -*- encoding: utf-8 -*-
2
+
1
3
  module Bluepill
2
4
  module Triggers
3
5
  class Flapping < Bluepill::Trigger
4
6
  TRIGGER_STATES = [:starting, :restarting]
5
-
7
+
6
8
  PARAMS = [:times, :within, :retry_in]
7
-
9
+
8
10
  attr_accessor *PARAMS
9
11
  attr_reader :timeline
10
-
12
+
11
13
  def initialize(process, options = {})
12
14
  options.reverse_merge!(:times => 5, :within => 1, :retry_in => 5)
13
-
15
+
14
16
  options.each_pair do |name, val|
15
17
  instance_variable_set("@#{name}", val) if PARAMS.include?(name)
16
18
  end
17
-
19
+
18
20
  @timeline = Util::RotationalArray.new(@times)
19
21
  super
20
22
  end
21
-
23
+
22
24
  def notify(transition)
23
25
  if TRIGGER_STATES.include?(transition.to_name)
24
26
  self.timeline << Time.now.to_i
25
27
  self.check_flapping
26
28
  end
27
29
  end
28
-
30
+
29
31
  def reset!
30
32
  @timeline.clear
31
33
  super
32
34
  end
33
-
35
+
34
36
  def check_flapping
35
37
  num_occurances = (@timeline.nitems == self.times)
36
-
38
+
37
39
  # The process has not flapped if we haven't encountered enough incidents
38
40
  return unless num_occurances
39
-
41
+
40
42
  # Check if the incident happend within the timeframe
41
43
  duration = (@timeline.last - @timeline.first) <= self.within
42
-
44
+
43
45
  if duration
44
46
  self.logger.info "Flapping detected: retrying in #{self.retry_in} seconds"
45
-
47
+
46
48
  self.schedule_event(:start, self.retry_in)
47
-
48
- # this happens in the process' thread so we don't have to worry about concurrency issues with this event
49
+
49
50
  self.dispatch!(:unmonitor)
50
-
51
+
51
52
  @timeline.clear
52
-
53
- # This will prevent a transition from happening in the process state_machine
54
- throw :halt
55
53
  end
56
54
  end
57
55
  end
@@ -1,23 +1,25 @@
1
+ # -*- encoding: utf-8 -*-
2
+
1
3
  module Bluepill
2
4
  module Util
3
5
  class RotationalArray < Array
4
6
  def initialize(size)
5
7
  super(size)
6
-
8
+
7
9
  @capacity = size
8
10
  @counter = 0
9
11
  end
10
-
12
+
11
13
  def push(value)
12
14
  idx = rotational_idx(@counter)
13
15
  self[idx] = value
14
-
16
+
15
17
  @counter += 1
16
18
  self
17
19
  end
18
-
20
+
19
21
  alias_method :<<, :push
20
-
22
+
21
23
  def pop
22
24
  raise "Cannot call pop on a rotational array"
23
25
  end
@@ -29,25 +31,25 @@ module Bluepill
29
31
  def unshift
30
32
  raise "Cannot call unshift on a rotational array"
31
33
  end
32
-
34
+
33
35
  def last
34
36
  return if @counter.zero?
35
-
37
+
36
38
  self[rotational_idx(@counter - 1)]
37
39
  end
38
-
40
+
39
41
  def first
40
42
  return if @counter.zero?
41
43
  return self[0] if @counter <= @capacity
42
-
44
+
43
45
  self[rotational_idx(@counter)]
44
46
  end
45
-
47
+
46
48
  def clear
47
49
  @counter = 0
48
50
  super
49
51
  end
50
-
52
+
51
53
  def each(&block)
52
54
  times = @counter >= @capacity ? @capacity : @counter
53
55
  start = @counter >= @capacity ? rotational_idx(@counter) : 0
@@ -61,9 +63,9 @@ module Bluepill
61
63
  compact.length
62
64
  end
63
65
  end
64
-
66
+
65
67
  private
66
-
68
+
67
69
  def rotational_idx(idx)
68
70
  idx % @capacity
69
71
  end
@@ -1,3 +1,5 @@
1
+ # -*- encoding: utf-8 -*-
2
+
1
3
  module Bluepill
2
- VERSION = "0.0.44"
4
+ VERSION = "0.0.47"
3
5
  end
@@ -1,8 +1,9 @@
1
1
  #! /usr/bin/env ruby
2
- $LOAD_PATH << 'lib/'
2
+ # -*- encoding: utf-8 -*-
3
3
 
4
4
  require 'rubygems'
5
5
  require 'bluepill'
6
+ require 'active_support'
6
7
  require 'logger'
7
8
 
8
9
  ROOT_DIR = "/tmp/bp"
@@ -1,3 +1,5 @@
1
+ # -*- encoding: utf-8 -*-
2
+
1
3
  require 'rubygems'
2
4
  require 'bluepill'
3
5
  require 'logger'
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 46
9
- version: 0.0.46
8
+ - 47
9
+ version: 0.0.47
10
10
  platform: ruby
11
11
  authors:
12
12
  - Stefan Huber
@@ -18,7 +18,7 @@ bindir: bin
18
18
  cert_chain: []
19
19
 
20
20
  date: 2011-01-10 00:00:00 +00:00
21
- default_executable: bluepill
21
+ default_executable:
22
22
  dependencies:
23
23
  - !ruby/object:Gem::Dependency
24
24
  name: daemons
@@ -26,13 +26,13 @@ dependencies:
26
26
  requirement: &id001 !ruby/object:Gem::Requirement
27
27
  none: false
28
28
  requirements:
29
- - - ">="
29
+ - - ~>
30
30
  - !ruby/object:Gem::Version
31
31
  segments:
32
32
  - 1
33
33
  - 0
34
- - 9
35
- version: 1.0.9
34
+ - 10
35
+ version: 1.0.10
36
36
  type: :runtime
37
37
  version_requirements: *id001
38
38
  - !ruby/object:Gem::Dependency
@@ -41,14 +41,14 @@ dependencies:
41
41
  requirement: &id002 !ruby/object:Gem::Requirement
42
42
  none: false
43
43
  requirements:
44
- - - ">="
44
+ - - ~>
45
45
  - !ruby/object:Gem::Version
46
46
  segments:
47
47
  - 2
48
48
  - 1
49
49
  - 2
50
- - 2
51
- version: 2.1.2.2
50
+ - 3
51
+ version: 2.1.2.3
52
52
  type: :runtime
53
53
  version_requirements: *id002
54
54
  - !ruby/object:Gem::Dependency
@@ -57,13 +57,13 @@ dependencies:
57
57
  requirement: &id003 !ruby/object:Gem::Requirement
58
58
  none: false
59
59
  requirements:
60
- - - ">="
60
+ - - ~>
61
61
  - !ruby/object:Gem::Version
62
62
  segments:
63
63
  - 0
64
64
  - 8
65
- - 0
66
- version: 0.8.0
65
+ - 1
66
+ version: 0.8.1
67
67
  type: :runtime
68
68
  version_requirements: *id003
69
69
  - !ruby/object:Gem::Dependency
@@ -72,13 +72,13 @@ dependencies:
72
72
  requirement: &id004 !ruby/object:Gem::Requirement
73
73
  none: false
74
74
  requirements:
75
- - - ">="
75
+ - - ~>
76
76
  - !ruby/object:Gem::Version
77
77
  segments:
78
78
  - 2
79
79
  - 3
80
- - 4
81
- version: 2.3.4
80
+ - 10
81
+ version: 2.3.10
82
82
  type: :runtime
83
83
  version_requirements: *id004
84
84
  - !ruby/object:Gem::Dependency
@@ -87,7 +87,7 @@ dependencies:
87
87
  requirement: &id005 !ruby/object:Gem::Requirement
88
88
  none: false
89
89
  requirements:
90
- - - ">="
90
+ - - ~>
91
91
  - !ruby/object:Gem::Version
92
92
  segments:
93
93
  - 1
@@ -97,22 +97,24 @@ dependencies:
97
97
  type: :runtime
98
98
  version_requirements: *id005
99
99
  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.
100
- email: MSNexploder@gmail.com
100
+ email:
101
+ - MSNexploder@gmail.com
101
102
  executables:
102
103
  - bluepill
104
+ - sample_forking_server
103
105
  extensions: []
104
106
 
105
- extra_rdoc_files:
106
- - LICENSE
107
- - README.md
107
+ extra_rdoc_files: []
108
+
108
109
  files:
110
+ - .gitignore
109
111
  - DESIGN.md
112
+ - Gemfile
110
113
  - LICENSE
111
114
  - README.md
112
115
  - Rakefile
113
- - VERSION
114
116
  - bin/bluepill
115
- - bin/bpsv
117
+ - bin/sample_forking_server
116
118
  - evented_bluepill.gemspec
117
119
  - lib/bluepill.rb
118
120
  - lib/bluepill/application.rb
@@ -121,6 +123,10 @@ files:
121
123
  - lib/bluepill/condition_watch.rb
122
124
  - lib/bluepill/controller.rb
123
125
  - lib/bluepill/dsl.rb
126
+ - lib/bluepill/dsl/app_proxy.rb
127
+ - lib/bluepill/dsl/process_factory.rb
128
+ - lib/bluepill/dsl/process_proxy.rb
129
+ - lib/bluepill/event.rb
124
130
  - lib/bluepill/group.rb
125
131
  - lib/bluepill/logger.rb
126
132
  - lib/bluepill/process.rb
@@ -166,7 +172,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
166
172
  version: "0"
167
173
  requirements: []
168
174
 
169
- rubyforge_project:
175
+ rubyforge_project: evented_bluepill
170
176
  rubygems_version: 1.3.7
171
177
  signing_key:
172
178
  specification_version: 3
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.0.46
data/bin/bpsv DELETED
@@ -1,3 +0,0 @@
1
- #!/bin/bash
2
- target=`basename $0`
3
- exec bluepill $1 $target