Class: Jesus::Interface

Inherits:
Object
  • Object
show all
Defined in:
lib/jesus/interface.rb

Overview

Interface between jesus and god

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeInterface

Returns a new instance of Interface.



10
11
12
# File 'lib/jesus/interface.rb', line 10

def initialize
    @server = DRbObject.new(nil, God::Socket.socket(17165))
end

Instance Attribute Details

#serverObject (readonly)

Returns the value of attribute server.



8
9
10
# File 'lib/jesus/interface.rb', line 8

def server
  @server
end

Instance Method Details

#command(command, name) ⇒ Object

We execute a specific command to god Could be “start”, “stop”, “restart”, “quit”, “terminate”



38
39
40
41
42
43
44
# File 'lib/jesus/interface.rb', line 38

def command(command, name)
  begin
    server.control(name, command)
  rescue
    return nil
  end
end

#log(name = nil, start = Time.at(0)) ⇒ Object

Gets the god’s logs for one process since some time By default, gets all the logs



50
51
52
53
54
55
56
# File 'lib/jesus/interface.rb', line 50

def log(name=nil, start=Time.at(0))
  begin
    server.running_log(name, start).split("\n")
  rescue
    nil
  end
end

#statusObject

We retrieve the processes by group



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/jesus/interface.rb', line 18

def status
  begin
    statuses = server.status
  rescue
    return nil
  end
  groups = Hash.new
  
  statuses.each do |name, status|
    g = status[:group] || ''
    groups[g] ||= Hash.new
    groups[g][name] = status
  end
  groups
end