Class: Cassie::Support::ServerProcess
- Defined in:
- lib/cassie/support/server_process.rb
Instance Attribute Summary collapse
-
#errors ⇒ Array<String>
readonly
The Cassandra output lines tagged with ERROR.
-
#log_path ⇒ Object
readonly
Returns the value of attribute log_path.
-
#pid ⇒ Object
readonly
Returns the value of attribute pid.
Class Method Summary collapse
-
.all ⇒ Array<ServerProcess>
Scan the system for cassandra processes running.
-
.log_path ⇒ Object
The path to the active cassandra binary’s log file Does not yet respect a configured log path, and assumes the path is relative to bin/casandra at ../logs/system.log.
Instance Method Summary collapse
- #command ⇒ Object
-
#initialize(pid = nil) ⇒ ServerProcess
constructor
Starts a cassandra server process.
-
#running? ⇒ Boolean
If the cassandra server started correctly.
-
#stop ⇒ Object
Stops the cassandra server processes, synchronously.
Constructor Details
#initialize(pid = nil) ⇒ ServerProcess
Starts a cassandra server process. #running? will be true if it started correctly.
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/cassie/support/server_process.rb', line 29 def initialize(pid=nil) @pid = pid @errors = [] if pid @running = true else start_cassandra end end |
Instance Attribute Details
#errors ⇒ Array<String> (readonly)
Returns The Cassandra output lines tagged with ERROR.
7 8 9 |
# File 'lib/cassie/support/server_process.rb', line 7 def errors @errors end |
#log_path ⇒ Object (readonly)
Returns the value of attribute log_path.
1 2 3 |
# File 'lib/cassie/support/server_process.rb', line 1 def log_path @log_path end |
#pid ⇒ Object (readonly)
Returns the value of attribute pid.
5 6 7 |
# File 'lib/cassie/support/server_process.rb', line 5 def pid @pid end |
Class Method Details
.all ⇒ Array<ServerProcess>
Scan the system for cassandra processes running
12 13 14 |
# File 'lib/cassie/support/server_process.rb', line 12 def self.all pids.map{|pid| new(pid)} end |
.log_path ⇒ Object
The path to the active cassandra binary’s log file Does not yet respect a configured log path, and assumes the path is relative to bin/casandra at ../logs/system.log
20 21 22 23 24 25 26 |
# File 'lib/cassie/support/server_process.rb', line 20 def self.log_path which = Cassie::Support::SystemCommand.new("which", ["cassandra"]) which.succeed bin_path = which.output.tr("\n", '') bin_path.sub('bin/cassandra', 'logs/system.log') end |
Instance Method Details
#command ⇒ Object
61 62 63 |
# File 'lib/cassie/support/server_process.rb', line 61 def command details[:command] end |
#running? ⇒ Boolean
Returns If the cassandra server started correctly. See #errors if false.
41 42 43 |
# File 'lib/cassie/support/server_process.rb', line 41 def running? !!@running end |
#stop ⇒ Object
Stops the cassandra server processes, synchronously.
47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/cassie/support/server_process.rb', line 47 def stop self.class.pids.each do|pid| Process.kill("TERM", pid) loop do sleep(0.1) begin Process.getpgid( pid ) rescue Errno::ESRCH break end end end end |