Method: Jets::RackServer#start

Defined in:
lib/jets/rack_server.rb

#startObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/jets/rack_server.rb', line 11

def start
  return unless File.exist?("#{rack_project}/config.ru")
  puts "Starting additional rack server for the project under the rack subfolder..." if ENV['JETS_DEBUG']

  if ENV['FOREGROUND']
    serve
    return
  end

  # Reaching here means we'll run the server in the background.
  # Handle daemonzing ourselves because it keeps the stdout of the 2nd
  # rack server. The rackup --daemonize option ends up hiding the output.
  pid = Process.fork
  if pid.nil?
    # we're in the child process
    serve
  else
    # we're in the parent process
    Process.detach(pid) # dettached but still in the "foreground" since bin/rackup runs in the foreground
  end
end