bluepill 0.0.11 → 0.0.12

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.11
1
+ 0.0.12
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.11"
8
+ s.version = "0.0.12"
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-03}
12
+ s.date = %q{2009-11-05}
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}
@@ -10,6 +10,7 @@ module Bluepill
10
10
 
11
11
  :daemonize,
12
12
  :pid_file,
13
+ :working_dir,
13
14
 
14
15
  :start_grace_time,
15
16
  :stop_grace_time,
@@ -230,12 +231,12 @@ module Bluepill
230
231
  logger.warning "Executing start command: #{start_command}"
231
232
 
232
233
  if self.daemonize?
233
- child_pid = System.daemonize(start_command, :uid => self.uid, :gid => self.gid)
234
+ child_pid = System.daemonize(start_command, self.system_command_options)
234
235
  File.open(pid_file, "w") {|f| f.write(child_pid)}
235
236
 
236
237
  else
237
238
  # This is a self-daemonizing process
238
- result = System.execute_blocking(start_command, :uid => self.uid, :gid => self.gid, :logger => logger)
239
+ result = System.execute_blocking(start_command, self.system_command_options)
239
240
 
240
241
  unless result[:exit_code].zero?
241
242
  logger.warning "Start command execution returned non-zero exit code:"
@@ -251,7 +252,7 @@ module Bluepill
251
252
  cmd = process_command(stop_command)
252
253
  logger.warning "Executing stop command: #{cmd}"
253
254
 
254
- result = System.execute_blocking(cmd, :uid => self.uid, :gid => self.gid)
255
+ result = System.execute_blocking(cmd, self.system_command_options)
255
256
  unless result[:exit_code].zero?
256
257
  logger.warning "Stop command execution returned non-zero exit code:"
257
258
  logger.warning result.inspect
@@ -272,7 +273,7 @@ module Bluepill
272
273
 
273
274
  logger.warning "Executing restart command: #{cmd}"
274
275
 
275
- result = System.execute_blocking(cmd, :uid => self.uid, :gid => self.gid)
276
+ result = System.execute_blocking(cmd, self.system_command_options)
276
277
 
277
278
  unless result[:exit_code].zero?
278
279
  logger.warning "Restart command execution returned non-zero exit code:"
@@ -371,6 +372,10 @@ module Bluepill
371
372
  def process_command(cmd)
372
373
  cmd.to_s.gsub("{{PID}}", actual_pid.to_s)
373
374
  end
375
+
376
+ def system_command_options
377
+ {:uid => self.uid, :gid => self.gid, :working_dir => self.working_dir, :logger => self.logger}
378
+ end
374
379
  end
375
380
  end
376
381
 
@@ -52,7 +52,13 @@ module Bluepill
52
52
 
53
53
  drop_privileges(options[:uid], options[:gid])
54
54
 
55
- daemon_id = Daemonize.call_as_daemon(lambda { ::Kernel.exec(cmd); exit }, nil, cmd)
55
+ to_daemonize = lambda do
56
+ Dir.chdir(options[:working_dir]) if options[:working_dir]
57
+ ::Kernel.exec(cmd)
58
+ exit
59
+ end
60
+
61
+ daemon_id = Daemonize.call_as_daemon(to_daemonize, nil, cmd)
56
62
 
57
63
  wr.write daemon_id
58
64
  wr.close
@@ -88,6 +94,8 @@ module Bluepill
88
94
  # grandchild
89
95
  drop_privileges(options[:uid], options[:gid])
90
96
 
97
+ Dir.chdir(options[:working_dir]) if options[:working_dir]
98
+
91
99
  # close unused fds so ancestors wont hang. This line is the only reason we are not
92
100
  # using something like popen3. If this fd is not closed, the .read call on the parent
93
101
  # will never return because "wr" would still be open in the "exec"-ed cmd
data/lib/example.rb CHANGED
@@ -46,7 +46,7 @@ Bluepill.application(:sample_app) do |app|
46
46
  end
47
47
  end
48
48
 
49
- 1.times do |i|
49
+ 0.times do |i|
50
50
  app.process("group_process_#{i}") do |process|
51
51
  process.group = "Poopfaced"
52
52
  process.pid_file = "/Users/rohith/ffs/tmp/pids/mongrel_#{i}.pid"
@@ -61,12 +61,12 @@ Bluepill.application(:sample_app) do |app|
61
61
  end
62
62
  end
63
63
 
64
- 0.times do |i|
64
+ 1.times do |i|
65
65
  app.process("group_process_#{i}") do |process|
66
- process.start_command = "sleep #{rand(30) + i}"
67
- process.group = "Poopfaced_2"
66
+ process.start_command = "./sleeper"
68
67
  process.daemonize = true
69
- process.pid_file = "#{ROOT_DIR}/pids/#{process.group}_process_#{i}.pid"
68
+ process.pid_file = "#{ROOT_DIR}/pids/process_#{i}.pid"
69
+ process.working_dir = '/tmp/somedir'
70
70
 
71
71
  process.checks :always_true, :every => 10
72
72
  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.11
4
+ version: 0.0.12
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-03 00:00:00 -08:00
14
+ date: 2009-11-05 00:00:00 -08:00
15
15
  default_executable: bluepill
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency