File: status.rb

package info (click to toggle)
ruby-spring 2.1.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, trixie
  • size: 428 kB
  • sloc: ruby: 3,373; sh: 9; makefile: 7
file content (30 lines) | stat: -rw-r--r-- 701 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
module Spring
  module Client
    class Status < Command
      def self.description
        "Show current status."
      end

      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

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

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