bluepill 0.0.17 → 0.0.18

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.17
1
+ 0.0.18
data/bin/bluepill CHANGED
@@ -20,18 +20,19 @@ OptionParser.new do |opts|
20
20
  end
21
21
  end.parse!
22
22
 
23
- APPLICATION_COMMANDS = %w(status start stop restart unmonitor quit)
23
+ APPLICATION_COMMANDS = %w(status start stop restart unmonitor quit log)
24
24
 
25
25
  controller = Bluepill::Controller.new(options.slice(:base_dir))
26
26
 
27
- if controller.list.include?(ARGV.first)
27
+ if controller.running_applications.include?(ARGV.first)
28
+ # the first arg is the application name
28
29
  options[:application] = ARGV.shift
29
30
  elsif APPLICATION_COMMANDS.include?(ARGV.first)
30
- if controller.list.length == 1
31
- options[:application] = controller.list.first
32
- elsif controller.list.length > 1
33
- $stderr.puts "You must specify an application name. Here's the list:"
34
- controller.list.each_with_index do |app, index|
31
+ if controller.running_applications.length == 1
32
+ options[:application] = controller.running_applications.first
33
+ elsif controller.running_applications.length > 1
34
+ $stderr.puts "You must specify an application name. Here's the list of running applications:"
35
+ controller.running_applications.each_with_index do |app, index|
35
36
  $stderr.puts " #{index + 1}. #{app}"
36
37
  end
37
38
  $stderr.puts "Usage: bluepill [app] cmd [options]"
@@ -47,20 +48,23 @@ options[:command] = ARGV.shift
47
48
  case options[:command]
48
49
  when "load"
49
50
  file = ARGV.shift
50
- eval(File.read(file))
51
-
51
+ if File.exists?(file)
52
+ eval(File.read(file))
53
+ else
54
+ $stderr.puts "Can't find file: #{file}"
55
+ end
52
56
  when "log"
53
57
  orig_pattern = pattern = ARGV.shift
54
58
  pattern = controller.send_cmd(options[:application], :grep_pattern, pattern)
55
59
 
56
60
  cmd = "tail -n 100 -f #{options[:log_file]} | grep -E '#{pattern}'"
57
- cmd = "echo 'Tailing log for #{orig_pattern}...'; #{cmd}"
61
+ puts "Tailing log for #{orig_pattern}..."
58
62
  Kernel.exec(cmd)
59
63
 
60
64
  when *APPLICATION_COMMANDS
61
65
  process_or_group_name = ARGV.shift
62
66
  puts controller.send_cmd(options[:application], options[:command], process_or_group_name)
63
-
67
+
64
68
  else
65
69
  puts "Unknown command `%s` (or application `%s` has not been loaded yet)" % [options[:command], options[:command]]
66
70
  end
data/bluepill.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{bluepill}
8
- s.version = "0.0.17"
8
+ s.version = "0.0.18"
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"]
@@ -14,12 +14,19 @@ module Bluepill
14
14
  cleanup
15
15
  end
16
16
 
17
- def list
17
+ def running_applications
18
18
  Dir[File.join(sockets_dir, "*.sock")].map{|x| File.basename(x, ".sock")}
19
19
  end
20
20
 
21
+ def send_cmd(application, command, *args)
22
+ applications[application] ||= Application.new(application, {:base_dir => base_dir})
23
+ applications[application].send(command.to_sym, *args.compact)
24
+ end
25
+
26
+ private
27
+
21
28
  def cleanup
22
- self.list.each do |app|
29
+ self.running_applications.each do |app|
23
30
  pid = pid_for(app)
24
31
  if !pid || !alive?(pid)
25
32
  pid_file = File.join(self.pids_dir, "#{app}.pid")
@@ -30,19 +37,11 @@ module Bluepill
30
37
  end
31
38
  end
32
39
 
33
- def send_cmd(application, command, *args)
34
- applications[application] ||= Application.new(application, {:base_dir => base_dir})
35
- applications[application].send(command.to_sym, *args.compact)
36
- end
37
-
38
- private
39
-
40
40
  def pid_for(app)
41
41
  pid_file = File.join(self.pids_dir, "#{app}.pid")
42
42
  File.exists?(pid_file) && File.read(pid_file).to_i
43
43
  end
44
44
 
45
-
46
45
  def alive?(pid)
47
46
  begin
48
47
  ::Process.kill(0, pid)
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.17
4
+ version: 0.0.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arya Asemanfar