Module: Idlc::Build::Httpd

Defined in:
lib/iapi-idlc-sdk-build/httpd.rb

Class Method Summary collapse

Class Method Details

.private_ipObject



5
6
7
# File 'lib/iapi-idlc-sdk-build/httpd.rb', line 5

def private_ip
  Socket.ip_address_list.detect(&:ipv4_private?).ip_address
end

.start(root_dir, sleep_time = 3) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/iapi-idlc-sdk-build/httpd.rb', line 9

def start(root_dir, sleep_time = 3)
  httpd = server(root_dir)

  pid = Process.fork
  if pid.nil?
    # In child
    exec((
      trap('INT') { httpd.shutdown }
      httpd.start
      # ignore the nil excpetion here, this happens when the child process exits
    )) rescue nil
  else
    # In parent
    Process.detach(pid)
  end

  sleep sleep_time

  # Return process id
  pid
end

.stop(pid) ⇒ Object



31
32
33
# File 'lib/iapi-idlc-sdk-build/httpd.rb', line 31

def stop(pid)
  Process.kill('INT', pid) unless pid.nil?
end