bluepill 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9c7760cf13b7c5d2f991f644fe1f762eca7853d3
4
- data.tar.gz: 28dc84d8bf94f0e2c5318f9397190fd35f6b626e
3
+ metadata.gz: 6007963ed9836bc609625037bd170bed8057cf37
4
+ data.tar.gz: 0dbdd5043c20fad925290da16d63ef423b18ba83
5
5
  SHA512:
6
- metadata.gz: 76da9cf314f0a7bb9f4181d895e321f9851bc801955e8bde47b10ec9b1ad6f41f8f0d58e9ef3c5f2d1144258272d772579e1fb3204d883cd71ed6ad9dcc076ee
7
- data.tar.gz: e25c6b9194bcc135e1a08339b58584c2962e9bc81129c019a91e5d162f52d8eeea73f63bb8195a77cef9191bdc423270725da0a6b1fee39ba7dd9045ef0b5daa
6
+ metadata.gz: 3a19e7ac04e1373bf37f2fbbeeef3bf827260326aa73573028d735da2acf03517469c6f5442a55826198dbd7b6dffec73b35aafa80e89f53ad1a5708db2d95ad
7
+ data.tar.gz: bb395f534f3f5ed497ed76318fcd72c898ff4bf9ff508ea1e657cb5f94e0891e8fea81436241285d299f54e42bcc2cdb036d48a50fd6e198502d9a308c8ef9e6
@@ -23,17 +23,6 @@ module Bluepill
23
23
  case command.to_sym
24
24
  when :status
25
25
  puts send_to_daemon(application, :status, *args)
26
- when *Application::PROCESS_COMMANDS
27
- # these need to be sent to the daemon and the results printed out
28
- affected = send_to_daemon(application, command, *args)
29
- if affected.empty?
30
- puts 'No processes effected'
31
- else
32
- puts "Sent #{command} to:"
33
- affected.each do |process|
34
- puts " #{process}"
35
- end
36
- end
37
26
  when :quit
38
27
  pid = pid_for(application)
39
28
  if System.pid_alive?(pid)
@@ -52,6 +41,17 @@ module Bluepill
52
41
  tail = "tail -n 100 -f #{log_file_location} | grep -E '#{grep_pattern}'"
53
42
  puts "Tailing log for #{requested_pattern}..."
54
43
  Kernel.exec(tail)
44
+ when *Application::PROCESS_COMMANDS
45
+ # these need to be sent to the daemon and the results printed out
46
+ affected = send_to_daemon(application, command, *args)
47
+ if affected.empty?
48
+ puts 'No processes effected'
49
+ else
50
+ puts "Sent #{command} to:"
51
+ affected.each do |process|
52
+ puts " #{process}"
53
+ end
54
+ end
55
55
  else
56
56
  $stderr.puts(format('Unknown command `%s` (or application `%s` has not been loaded yet)', command, command))
57
57
  exit(1)
@@ -86,7 +86,7 @@ module Bluepill
86
86
  def cleanup_bluepill_directory
87
87
  running_applications.each do |app|
88
88
  pid = pid_for(app)
89
- next if pid || System.pid_alive?(pid)
89
+ next if pid && System.pid_alive?(pid)
90
90
  pid_file = File.join(pids_dir, "#{app}.pid")
91
91
  sock_file = File.join(sockets_dir, "#{app}.sock")
92
92
  System.delete_if_exists(pid_file)
@@ -331,7 +331,7 @@ module Bluepill
331
331
  logger.warning result.inspect
332
332
  end
333
333
  end
334
-
334
+ cleanup_process
335
335
  elsif stop_signals
336
336
  # issue stop signals with configurable delay between each
337
337
  logger.warning "Sending stop signals to #{actual_pid}"
@@ -355,13 +355,13 @@ module Bluepill
355
355
  logger.info "Sending signal #{signal} to #{process.actual_pid}"
356
356
  process.signal_process(signal)
357
357
  end
358
+ cleanup_process
358
359
  end
359
360
  else
360
361
  logger.warning "Executing default stop command. Sending TERM signal to #{actual_pid}"
361
362
  signal_process('TERM')
363
+ cleanup_process
362
364
  end
363
- ProcessJournal.kill_all_from_journal(name) # finish cleanup
364
- unlink_pid # TODO: we only write the pid file if we daemonize, should we only unlink it if we daemonize?
365
365
 
366
366
  skip_ticks_for(stop_grace_time)
367
367
  end
@@ -389,6 +389,11 @@ module Bluepill
389
389
  end
390
390
  end
391
391
 
392
+ def cleanup_process
393
+ ProcessJournal.kill_all_from_journal(name) # finish cleanup
394
+ unlink_pid # TODO: we only write the pid file if we daemonize, should we only unlink it if we daemonize?
395
+ end
396
+
392
397
  def clean_threads
393
398
  @threads.each(&:kill)
394
399
  @threads.clear
@@ -26,6 +26,8 @@ module Bluepill
26
26
  true
27
27
  rescue Errno::ESRCH
28
28
  false
29
+ rescue
30
+ false # other falsy (no pid)
29
31
  end
30
32
 
31
33
  def cpu_usage(pid, include_children)
@@ -197,7 +199,7 @@ module Bluepill
197
199
  result = {
198
200
  stdout: cmd_out_read.read,
199
201
  stderr: cmd_err_read.read,
200
- exit_code: $CHILD_STATUS.exitstatus,
202
+ exit_code: $?.exitstatus,
201
203
  }
202
204
 
203
205
  # We're done with these ends of the pipes as well
@@ -14,7 +14,7 @@ module Bluepill
14
14
 
15
15
  # @return [Integer]
16
16
  def patch
17
- 1
17
+ 2
18
18
  end
19
19
 
20
20
  # @return [Integer, NilClass]
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.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arya Asemanfar
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2015-08-14 00:00:00.000000000 Z
13
+ date: 2016-06-19 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport
@@ -145,7 +145,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
145
145
  version: '0'
146
146
  requirements: []
147
147
  rubyforge_project:
148
- rubygems_version: 2.4.5
148
+ rubygems_version: 2.5.1
149
149
  signing_key:
150
150
  specification_version: 4
151
151
  summary: A process monitor written in Ruby with stability and minimalism in mind.