Class: Spring::Client::Status

Inherits:
Command
  • Object
show all
Defined in:
lib/spring/client/status.rb

Instance Attribute Summary

Attributes inherited from Command

#args, #env

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Command

call, #initialize

Constructor Details

This class inherits a constructor from Spring::Client::Command

Class Method Details

.descriptionObject



4
5
6
# File 'lib/spring/client/status.rb', line 4

def self.description
  "Show current status."
end

Instance Method Details

#application_pidsObject



23
24
25
26
27
# File 'lib/spring/client/status.rb', line 23

def application_pids
  candidates = `ps -ax -o ppid= -o pid=`.lines
  candidates.select { |l| l =~ /^(\s+)?#{env.pid} / }
            .map    { |l| l.split(" ").last   }
end

#callObject



8
9
10
11
12
13
14
15
16
17
# File 'lib/spring/client/status.rb', line 8

def call
  if env.server_running?
    puts "Spring is running:"
    puts
    print_process env.pid
    application_pids.each { |pid| print_process pid }
  else
    puts "Spring is not running."
  end
end


19
20
21
# File 'lib/spring/client/status.rb', line 19

def print_process(pid)
  puts `ps -p #{pid} -o pid= -o command=`
end