bluepill 0.0.23 → 0.0.24

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.23
1
+ 0.0.24
data/bin/bluepill CHANGED
@@ -29,8 +29,8 @@ OptionParser.new do |opts|
29
29
  puts "bluepill, version #{Bluepill::VERSION}"
30
30
  exit
31
31
  end
32
-
33
- opts.on_tail('-h','--help', 'Show this message') do
32
+
33
+ help = lambda do
34
34
  puts opts
35
35
  puts
36
36
  puts "Commands:"
@@ -46,6 +46,9 @@ OptionParser.new do |opts|
46
46
  puts "See http://github.com/arya/bluepill for README"
47
47
  exit
48
48
  end
49
+
50
+ opts.on_tail('-h','--help', 'Show this message', &help)
51
+ help.call if ARGV.empty?
49
52
  end.parse!
50
53
 
51
54
  APPLICATION_COMMANDS = %w(status start stop restart unmonitor quit log)
data/bluepill.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{bluepill}
8
- s.version = "0.0.23"
8
+ s.version = "0.0.24"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Arya Asemanfar", "Gary Tsang", "Rohith Ravi"]
12
- s.date = %q{2009-11-22}
12
+ s.date = %q{2009-11-24}
13
13
  s.default_executable = %q{bluepill}
14
14
  s.description = %q{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.}
15
15
  s.email = %q{entombedvirus@gmail.com}
@@ -48,7 +48,7 @@ module Bluepill
48
48
  # use (@history[(@history_index - 1)..1] + @history[0..(@history_index - 1)]).
49
49
  # collect {|v| "#{v[0]}#{v[1] ? '' : '*'}"}.join(", ")
50
50
  # but that's gross so... it's gonna be out of order till we figure out a better way to get it in order
51
- data = @history.collect {|v| "#{v[0]}#{v[1] ? '' : '*'}" if v}.compact.join(", ")
51
+ data = @history.collect {|v| "#{@process_condition.format_value(v[0])}#{v[1] ? '' : '*'}" if v}.compact.join(", ")
52
52
  "#{@name}: [#{data}]"
53
53
  end
54
54
  end
@@ -135,7 +135,7 @@ module Bluepill
135
135
  # State machine methods
136
136
  def dispatch!(event)
137
137
  @event_mutex.synchronize do
138
- self.send("#{event}!")
138
+ self.send("#{event}")
139
139
  end
140
140
  end
141
141
 
@@ -317,7 +317,8 @@ module Bluepill
317
317
  @actual_pid ||= begin
318
318
  if pid_file
319
319
  if File.exists?(pid_file)
320
- File.read(pid_file).to_i
320
+ str = File.read(pid_file)
321
+ str.to_i if str.size > 0
321
322
  else
322
323
  logger.warning("pid_file #{pid_file} does not exist or cannot be read")
323
324
  nil
@@ -1,6 +1,11 @@
1
1
  module Bluepill
2
2
  module ProcessConditions
3
3
  class MemUsage < ProcessCondition
4
+ MB = 1024 ** 2
5
+ FORMAT_STR = "%d%s"
6
+ MB_LABEL = "MB"
7
+ KB_LABEL = "KB"
8
+
4
9
  def initialize(options = {})
5
10
  @below = options[:below]
6
11
  end
@@ -13,6 +18,14 @@ module Bluepill
13
18
  def check(value)
14
19
  value.kilobytes < @below
15
20
  end
21
+
22
+ def format_value(value)
23
+ if value.kilobytes >= MB
24
+ FORMAT_STR % [(value / 1024).round, MB_LABEL]
25
+ else
26
+ FORMAT_STR % [value, KB_LABEL]
27
+ end
28
+ end
16
29
  end
17
30
  end
18
31
  end
@@ -8,6 +8,10 @@ module Bluepill
8
8
  def check(value)
9
9
  raise "Implement in subclass!"
10
10
  end
11
+
12
+ def format_value(value)
13
+ value
14
+ end
11
15
  end
12
16
  end
13
17
  end
@@ -1,3 +1,3 @@
1
1
  module Bluepill
2
- VERSION = "0.0.23"
2
+ VERSION = "0.0.24"
3
3
  end
data/lib/example.rb CHANGED
@@ -63,7 +63,7 @@ Bluepill.application(:sample_app) do |app|
63
63
 
64
64
  1.times do |i|
65
65
  app.process("group_process_#{i}") do |process|
66
- process.uid = "rohith"
66
+ process.uid = "arya"
67
67
  process.gid = "wheel"
68
68
 
69
69
  process.stderr = "/tmp/err.log"
@@ -71,11 +71,22 @@ Bluepill.application(:sample_app) do |app|
71
71
 
72
72
 
73
73
  process.group = "grouped"
74
- process.start_command = %Q{cd /tmp && ruby -e '$stderr.puts("hello stderr");$stdout.puts("hello stdout"); $stdout.flush; $stderr.flush; sleep 10'}
74
+ # process.start_command = %Q{cd /tmp && ruby -e '$stderr.puts("hello stderr");$stdout.puts("hello stdout"); $stdout.flush; $stderr.flush; sleep 10'}
75
+ process.start_command = "sleep 10"
75
76
  process.daemonize = true
76
- process.pid_file = "/tmp/noperm/p_#{process.group}_#{i}.pid"
77
+ process.pid_file = "/tmp/p_#{process.group}_#{i}.pid"
77
78
 
78
79
  # process.checks :always_true, :every => 5
80
+ process.checks :cpu_usage,
81
+ :every => 10,
82
+ :below => 0.5,
83
+ :times => [5, 5]
84
+
85
+ process.checks :mem_usage,
86
+ :every => 3,
87
+ :below => 600.megabytes,
88
+ :times => [3, 5],
89
+ :fires => [:stop]
79
90
  end
80
91
  end
81
92
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bluepill
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.23
4
+ version: 0.0.24
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arya Asemanfar
@@ -11,7 +11,7 @@ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
13
 
14
- date: 2009-11-22 00:00:00 -08:00
14
+ date: 2009-11-24 00:00:00 -08:00
15
15
  default_executable: bluepill
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency