bluepill 0.0.30 → 0.0.31

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.30
1
+ 0.0.31
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.30"
8
+ s.version = "0.0.31"
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-12-27}
12
+ s.date = %q{2010-01-15}
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}
@@ -78,7 +78,11 @@ module Bluepill
78
78
  begin
79
79
  client = self.socket.accept
80
80
  command, *args = client.readline.strip.split(":")
81
- response = self.send(command, *args)
81
+ response = begin
82
+ self.send(command, *args)
83
+ rescue Exception => e
84
+ e
85
+ end
82
86
  client.write(Marshal.dump(response))
83
87
  rescue StandardError => e
84
88
  logger.err("Got exception in cmd listener: %s `%s`" % [e.class.name, e.message])
@@ -18,7 +18,7 @@ module Bluepill
18
18
  end
19
19
 
20
20
  def run(pid, tick_number = Time.now.to_i)
21
- if @last_ran_at.nil? || (@last_ran_at + @every) <= tick_number
21
+ if true || @last_ran_at.nil? || (@last_ran_at + @every) <= tick_number
22
22
  @last_ran_at = tick_number
23
23
  self.record_value(@process_condition.run(pid))
24
24
  return @fires if self.fired?
@@ -66,7 +66,19 @@ module Bluepill
66
66
  while line = socket.gets
67
67
  buffer << line
68
68
  end
69
- Marshal.load(buffer)
69
+ if buffer.size > 0
70
+ response = Marshal.load(buffer)
71
+ if response.is_a?(Exception)
72
+ $stderr.puts "Received error from server:"
73
+ $stderr.puts response.inspect
74
+ $stderr.puts response.backtrace.join("\n")
75
+ exit(8)
76
+ else
77
+ response
78
+ end
79
+ else
80
+ abort("No response from server")
81
+ end
70
82
  end
71
83
  rescue Timeout::Error
72
84
  abort("Socket Timeout: Server may not be responding")
@@ -1,3 +1,3 @@
1
1
  module Bluepill
2
- VERSION = "0.0.30"
2
+ VERSION = "0.0.31"
3
3
  end
data/lib/example.rb CHANGED
@@ -3,13 +3,12 @@ require 'bluepill'
3
3
  require 'logger'
4
4
 
5
5
  ROOT_DIR = "/tmp/bp"
6
- Bluepill.define_process_condition(:random_watch) do
6
+ Bluepill.define_process_condition(:always_false) do
7
7
  def run(pid)
8
- (rand * 100).to_i / 100.0
8
+ 0
9
9
  end
10
10
 
11
11
  def check(value)
12
- value > @options[:fails_at]
13
12
  false
14
13
  end
15
14
  end
@@ -71,24 +70,25 @@ Bluepill.application(:sample_app) do |app|
71
70
  end
72
71
  end
73
72
 
74
- 2.times do |i|
73
+ 3.times do |i|
75
74
  app.process("group_process_#{i}") do |process|
76
- process.uid = "arya"
77
- process.gid = "wheel"
75
+ # process.uid = "deploy"
76
+ # process.gid = "deploy"
78
77
 
79
- process.stderr = "/tmp/err.log"
80
- process.stdout = "/tmp/err.log"
78
+ # process.stderr = "/tmp/err.log"
79
+ # process.stdout = "/tmp/err.log"
81
80
 
81
+ # process.group = "grouped"
82
82
 
83
- process.group = "grouped"
84
- # process.start_command = %Q{cd /tmp && ruby -e '$stderr.puts("hello stderr");$stdout.puts("hello stdout"); $stdout.flush; $stderr.flush; sleep 10'}
85
- process.start_command = "sleep 20"
83
+ process.start_command = "sleep 10"
86
84
  process.stop_command = "kill {{PID}}"
87
85
  process.daemonize = true
88
- process.pid_file = "/tmp/p_#{process.group}_#{i}.pid"
86
+ process.pid_file = "/tmp/process_#{i}.pid"
89
87
 
90
- process.checks :random_watch, :every => 2, :fails_at => 0.5
91
- process.checks :flapping, :times => 2, :within => 900.seconds, :retry_in => 7.seconds
88
+ process.checks :always_false, :every => 1, :times => [20,21]
89
+ process.checks :flapping, :times => 200, :within => 900.seconds, :retry_in => 7.seconds
90
+ process.checks :mem_usage, :every => 1, :below => 300.megabytes, :times => [3,5]
91
+ process.checks :cpu_usage, :every => 1, :below => 3000, :times => [3,5]
92
92
  end
93
93
  end
94
94
  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.30
4
+ version: 0.0.31
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-12-27 00:00:00 -08:00
14
+ date: 2010-01-15 00:00:00 -08:00
15
15
  default_executable: bluepill
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency