Module: Phlexite::Cli::Server

Defined in:
lib/phlexite/cli/server.rb

Class Method Summary collapse

Class Method Details

.start(port, build_dir) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/phlexite/cli/server.rb', line 4

def self.start(port, build_dir)
  port ||= 3000
  build_dir ||= "./_build"
  root = File.expand_path build_dir
  server = WEBrick::HTTPServer.new Port: port, DocumentRoot: root

  trap "INT" do
    server.shutdown
  end

  Thread.new { server.start }
end