commit
4fa4ad2232
|
@ -82,6 +82,7 @@ command :serve do |c|
|
|||
c.option '--limit_posts MAX_POSTS', Integer, 'Limits the number of posts to parse and publish'
|
||||
c.option '-w', '--watch', 'Watch for changes and rebuild'
|
||||
c.option '--lsi', 'Use LSI for improved related posts'
|
||||
c.option '-B', '--detach', 'Run the server in the background (detach)'
|
||||
c.option '-D', '--drafts', 'Render posts in the _drafts folder'
|
||||
|
||||
c.option '-P', '--port [PORT]', 'Port to listen on'
|
||||
|
|
|
@ -24,6 +24,12 @@ module Jekyll
|
|||
)
|
||||
|
||||
s.mount(options['baseurl'], HTTPServlet::FileHandler, destination, fh_option)
|
||||
|
||||
if options['detach'] # detach the server
|
||||
pid = Process.fork {s.start}
|
||||
Process.detach(pid)
|
||||
pid
|
||||
else # create a new server thread, then join it with current terminal
|
||||
t = Thread.new { s.start }
|
||||
trap("INT") { s.shutdown }
|
||||
t.join()
|
||||
|
@ -31,3 +37,4 @@ module Jekyll
|
|||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -15,6 +15,7 @@ module Jekyll
|
|||
'timezone' => nil, # use the local timezone
|
||||
|
||||
'safe' => false,
|
||||
'detach' => false, # default to not detaching the server
|
||||
'show_drafts' => nil,
|
||||
'limit_posts' => 0,
|
||||
'lsi' => false,
|
||||
|
|
|
@ -220,6 +220,16 @@ before your site is served.
|
|||
<p><code class="flag">--baseurl URL</code></p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class='setting'>
|
||||
<td>
|
||||
<p class='name'><strong>Detach</strong></p>
|
||||
<p class='description'>Detach the server from the terminal</p>
|
||||
</td>
|
||||
<td class="align-center">
|
||||
<p><code class="option">detach: BOOL</code></p>
|
||||
<p><code class="flag">-B, --detach</code></p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
|
|
@ -31,8 +31,13 @@ preview what the generated site will look like in your browser locally.
|
|||
$ jekyll serve
|
||||
# => A development server will run at http://localhost:4000/
|
||||
|
||||
$ jekyll serve --detach
|
||||
# => Same as `jekyll serve` but will detach from the current terminal.
|
||||
# If you need to kill the server, you can `kill -9 1234` where "1234" is the PID.
|
||||
# If you cannot find the PID, then do, `ps aux | grep jekyll` and kill the instance. [Read more](http://unixhelp.ed.ac.uk/shell/jobz5.html).
|
||||
|
||||
$ jekyll serve --watch
|
||||
# => As above, but watch for changes and regenerate automatically.
|
||||
# => Same as `jekyll serve`, but watch for changes and regenerate automatically.
|
||||
{% endhighlight %}
|
||||
|
||||
This is just a few of the available [configuration options](../configuration/).
|
||||
|
|
Loading…
Reference in New Issue