Class: Supervisor::Server
- Inherits:
-
Object
- Object
- Supervisor::Server
- Defined in:
- lib/supervisor/server.rb
Constant Summary collapse
- @@instance_collector =
[]
Instance Attribute Summary collapse
-
#connection ⇒ Object
Returns the value of attribute connection.
-
#host ⇒ Object
Returns the value of attribute host.
-
#name ⇒ Object
Returns the value of attribute name.
-
#rails_path ⇒ Object
Returns the value of attribute rails_path.
Class Method Summary collapse
Instance Method Summary collapse
- #delayed_job_workers ⇒ Object
-
#initialize(name = "default", host = "localhost", rails_path = nil, username = nil, password = nil) ⇒ Server
constructor
A new instance of Server.
Constructor Details
#initialize(name = "default", host = "localhost", rails_path = nil, username = nil, password = nil) ⇒ Server
Returns a new instance of Server.
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/supervisor/server.rb', line 8 def initialize(name="default",host="localhost",rails_path=nil,username=nil,password=nil) unless host == "localhost" p host @connection = Net::SSH.start(host,username,:password=>password) @username = username else @connection = nil end @rails_path = rails_path @name = name @host = host @@instance_collector << self end |
Instance Attribute Details
#connection ⇒ Object
Returns the value of attribute connection.
6 7 8 |
# File 'lib/supervisor/server.rb', line 6 def connection @connection end |
#host ⇒ Object
Returns the value of attribute host.
6 7 8 |
# File 'lib/supervisor/server.rb', line 6 def host @host end |
#name ⇒ Object
Returns the value of attribute name.
6 7 8 |
# File 'lib/supervisor/server.rb', line 6 def name @name end |
#rails_path ⇒ Object
Returns the value of attribute rails_path.
6 7 8 |
# File 'lib/supervisor/server.rb', line 6 def rails_path @rails_path end |
Class Method Details
.servers ⇒ Object
22 23 24 |
# File 'lib/supervisor/server.rb', line 22 def self.servers return @@instance_collector end |
Instance Method Details
#delayed_job_workers ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/supervisor/server.rb', line 26 def delayed_job_workers @worker_list = [] if self.connection workers = connection.exec!("ps aux").split(/\n/).map{|x| x.split(/\s+/) if x.split(/\s+/).last.match("job")}.compact else workers = %x{ps aux}.split(/\n/).map{|x| x.split(/\s+/) if x.split(/\s+/).last.match("job")}.compact end if workers.any? workers.each do |wkr| @worker_list << Hashie::Mash.new({:host=>host,:name=>wkr.last,:pid=>wkr[1],:cpu=>wkr[2],:mem=>wkr[3],:started=>wkr[8],:run_time=>wkr[9]}) end return @worker_list else return nil end end |