11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/haze.rb', line 11
def self.start
require 'socket'
@thread = Thread.new {
s = TCPServer.new('127.0.0.1', 5555)
begin
loop do
conn = s.accept
request = conn.read
json = JSON.parse(request)
response = case json['action']
when 'vm create'
VM.create(json['options'])
when 'vm remove'
VM.remove(json['options'])
when 'vm list'
VM.list
end
puts response
conn.print response
conn.close_write
conn.close
end
rescue Exception => e
retry
end
}
require_relative 'haze/server'
end
|