Class: Nsqadmin
- Inherits:
-
ProcessWrapper
- Object
- ProcessWrapper
- Nsqadmin
- Defined in:
- lib/nsq-cluster/nsqadmin.rb
Constant Summary
Constants inherited from ProcessWrapper
ProcessWrapper::HTTPCHECK_INTERVAL
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#http_port ⇒ Object
readonly
Returns the value of attribute http_port.
Attributes inherited from ProcessWrapper
Instance Method Summary collapse
- #args ⇒ Object
- #command ⇒ Object
-
#initialize(opts = {}, verbose = false) ⇒ Nsqadmin
constructor
A new instance of Nsqadmin.
- #stop(opts = {}) ⇒ Object
Methods inherited from ProcessWrapper
#another_instance_is_running?, #block_until_running, #block_until_stopped, #destroy, #output, #running?, #start
Constructor Details
#initialize(opts = {}, verbose = false) ⇒ Nsqadmin
Returns a new instance of Nsqadmin.
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/nsq-cluster/nsqadmin.rb', line 9 def initialize(opts = {}, verbose = false) super @host = '127.0.0.1' @http_port = opts.delete(:http_port) || 4171 @lookupd = opts.delete(:nsqlookupd) || [] @extra_args = opts.map do |key, value| "--#{key.to_s.gsub('_', '-')}=#{value}" end end |
Instance Attribute Details
#host ⇒ Object (readonly)
Returns the value of attribute host.
7 8 9 |
# File 'lib/nsq-cluster/nsqadmin.rb', line 7 def host @host end |
#http_port ⇒ Object (readonly)
Returns the value of attribute http_port.
7 8 9 |
# File 'lib/nsq-cluster/nsqadmin.rb', line 7 def http_port @http_port end |
Instance Method Details
#args ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/nsq-cluster/nsqadmin.rb', line 35 def args base_args = [ %Q(--http-address=#{@host}:#{@http_port}) ] lookupd_args = @lookupd.map do |ld| %Q(--lookupd-http-address=#{ld.host}:#{ld.http_port}) end base_args + @extra_args + lookupd_args end |
#command ⇒ Object
30 31 32 |
# File 'lib/nsq-cluster/nsqadmin.rb', line 30 def command 'nsqadmin' end |
#stop(opts = {}) ⇒ Object
22 23 24 25 26 27 |
# File 'lib/nsq-cluster/nsqadmin.rb', line 22 def stop(opts = {}) Sys::ProcTable.ps.select{|pe| pe.ppid == @pid}.each do |child_pid| Process.kill('TERM', child_pid) end super end |