start server after jekyll processing so webrick has something to serve
This commit is contained in:
parent
8a2a42ba71
commit
8ed84a7590
|
@ -141,9 +141,10 @@ have it used instead:
|
||||||
When previewing complex sites locally, simply opening the site in a web
|
When previewing complex sites locally, simply opening the site in a web
|
||||||
browser (using file://) can cause problems with links that are relative to
|
browser (using file://) can cause problems with links that are relative to
|
||||||
the site root (e.g., "/stylesheets/style.css"). To get around this, Jekyll
|
the site root (e.g., "/stylesheets/style.css"). To get around this, Jekyll
|
||||||
can launch a simple WEBrick server (works well in conjunction with --auto):
|
can launch a simple WEBrick server (works well in conjunction with --auto).
|
||||||
|
Default port is 4000:
|
||||||
|
|
||||||
$ jekyll --server
|
$ jekyll --server [PORT]
|
||||||
|
|
||||||
h2. Data
|
h2. Data
|
||||||
|
|
||||||
|
|
38
bin/jekyll
38
bin/jekyll
|
@ -83,24 +83,6 @@ case ARGV.size
|
||||||
exit(1)
|
exit(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
if options[:server]
|
|
||||||
require 'webrick'
|
|
||||||
include WEBrick
|
|
||||||
|
|
||||||
s = HTTPServer.new(
|
|
||||||
:Port => options[:server_port],
|
|
||||||
:DocumentRoot => destination
|
|
||||||
)
|
|
||||||
t = Thread.new {
|
|
||||||
s.start
|
|
||||||
}
|
|
||||||
|
|
||||||
unless options[:auto]
|
|
||||||
trap("INT") { s.shutdown }
|
|
||||||
t.join()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if options[:auto]
|
if options[:auto]
|
||||||
require 'directory_watcher'
|
require 'directory_watcher'
|
||||||
|
|
||||||
|
@ -118,7 +100,27 @@ if options[:auto]
|
||||||
|
|
||||||
dw.start
|
dw.start
|
||||||
|
|
||||||
|
unless options[:server]
|
||||||
loop { sleep 1000 }
|
loop { sleep 1000 }
|
||||||
|
end
|
||||||
else
|
else
|
||||||
Jekyll.process(source, destination)
|
Jekyll.process(source, destination)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if options[:server]
|
||||||
|
require 'webrick'
|
||||||
|
include WEBrick
|
||||||
|
|
||||||
|
FileUtils.mkdir_p(destination)
|
||||||
|
|
||||||
|
s = HTTPServer.new(
|
||||||
|
:Port => options[:server_port],
|
||||||
|
:DocumentRoot => destination
|
||||||
|
)
|
||||||
|
t = Thread.new {
|
||||||
|
s.start
|
||||||
|
}
|
||||||
|
|
||||||
|
trap("INT") { s.shutdown }
|
||||||
|
t.join()
|
||||||
|
end
|
Loading…
Reference in New Issue