From 4e52869f0f5b6eb5a46fe723f921a7a65a534674 Mon Sep 17 00:00:00 2001 From: ddavison Date: Wed, 21 Aug 2013 20:53:01 +0000 Subject: [PATCH 1/6] adding detachment functionality --- bin/jekyll | 1 + lib/jekyll/commands/serve.rb | 14 +++++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/bin/jekyll b/bin/jekyll index bfe13068..68d16bd4 100755 --- a/bin/jekyll +++ b/bin/jekyll @@ -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 '--detach', 'Run this server in the background' c.option '-D', '--drafts', 'Render posts in the _drafts folder' c.option '-P', '--port [PORT]', 'Port to listen on' diff --git a/lib/jekyll/commands/serve.rb b/lib/jekyll/commands/serve.rb index ae28665b..8ff4ec6a 100644 --- a/lib/jekyll/commands/serve.rb +++ b/lib/jekyll/commands/serve.rb @@ -24,9 +24,17 @@ module Jekyll ) s.mount(options['baseurl'], HTTPServlet::FileHandler, destination, fh_option) - t = Thread.new { s.start } - trap("INT") { s.shutdown } - t.join() + + unless options['detach'] + t = Thread.new { s.start } + trap("INT") { s.shutdown } + t.join() + else + # they are detaching the server. + pid = Process.fork {s.start} + Process.detach(pid) + pid + end end end end From 9681f3a7761cd459a4b21126428ad000c6e68bbb Mon Sep 17 00:00:00 2001 From: ddavison Date: Wed, 21 Aug 2013 21:00:18 +0000 Subject: [PATCH 2/6] adding default configuration to false --- lib/jekyll/configuration.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/jekyll/configuration.rb b/lib/jekyll/configuration.rb index e00db8b1..0efc1d40 100644 --- a/lib/jekyll/configuration.rb +++ b/lib/jekyll/configuration.rb @@ -15,6 +15,7 @@ module Jekyll 'timezone' => nil, # use the local timezone 'safe' => false, + 'detach' => false, # don't default to detaching the server 'show_drafts' => nil, 'limit_posts' => 0, 'lsi' => false, From 8efcca9ddc7d4b32845b69aebee2e6d2188cd3b1 Mon Sep 17 00:00:00 2001 From: ddavison Date: Wed, 21 Aug 2013 21:10:42 +0000 Subject: [PATCH 3/6] adding documentation on using detach --- site/docs/configuration.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/site/docs/configuration.md b/site/docs/configuration.md index ce9f133c..1e734f60 100644 --- a/site/docs/configuration.md +++ b/site/docs/configuration.md @@ -220,6 +220,16 @@ before your site is served.

--baseurl URL

+ + +

Detach

+

Detach the server from the terminal

+ + +

detach: BOOL

+

--detach

+ + From 8463e62d929f8dc51132734b8c1b2ddc052b6e94 Mon Sep 17 00:00:00 2001 From: ddavison Date: Thu, 22 Aug 2013 13:45:06 +0000 Subject: [PATCH 4/6] adding note about running detached --- site/docs/usage.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/site/docs/usage.md b/site/docs/usage.md index ac09c40a..0a72e3d3 100644 --- a/site/docs/usage.md +++ b/site/docs/usage.md @@ -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/). From aedac6060b3b243b3cd6b42d9e6f919c23e6d701 Mon Sep 17 00:00:00 2001 From: ddavison Date: Fri, 23 Aug 2013 01:19:41 -0400 Subject: [PATCH 5/6] adding new -B flag for -background- --- bin/jekyll | 2 +- site/docs/configuration.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/jekyll b/bin/jekyll index 68d16bd4..70a66a00 100755 --- a/bin/jekyll +++ b/bin/jekyll @@ -82,7 +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 '--detach', 'Run this server in the background' + c.option '-B', '--detach', 'Run this server in the background (detach)' c.option '-D', '--drafts', 'Render posts in the _drafts folder' c.option '-P', '--port [PORT]', 'Port to listen on' diff --git a/site/docs/configuration.md b/site/docs/configuration.md index 1e734f60..05f2e1f4 100644 --- a/site/docs/configuration.md +++ b/site/docs/configuration.md @@ -227,7 +227,7 @@ before your site is served.

detach: BOOL

-

--detach

+

-B, --detach

From b163bf637e9380b108722d29e93ddc5958f90723 Mon Sep 17 00:00:00 2001 From: ddavison Date: Sat, 24 Aug 2013 21:31:05 -0400 Subject: [PATCH 6/6] final mods --- bin/jekyll | 2 +- lib/jekyll/commands/serve.rb | 11 +++++------ lib/jekyll/configuration.rb | 2 +- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/bin/jekyll b/bin/jekyll index 70a66a00..ddcbe123 100755 --- a/bin/jekyll +++ b/bin/jekyll @@ -82,7 +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 this server in the background (detach)' + 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' diff --git a/lib/jekyll/commands/serve.rb b/lib/jekyll/commands/serve.rb index 8ff4ec6a..406d3ef7 100644 --- a/lib/jekyll/commands/serve.rb +++ b/lib/jekyll/commands/serve.rb @@ -25,15 +25,14 @@ module Jekyll s.mount(options['baseurl'], HTTPServlet::FileHandler, destination, fh_option) - unless options['detach'] - t = Thread.new { s.start } - trap("INT") { s.shutdown } - t.join() - else - # they are detaching the server. + 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() end end end diff --git a/lib/jekyll/configuration.rb b/lib/jekyll/configuration.rb index 0efc1d40..05a097c7 100644 --- a/lib/jekyll/configuration.rb +++ b/lib/jekyll/configuration.rb @@ -15,7 +15,7 @@ module Jekyll 'timezone' => nil, # use the local timezone 'safe' => false, - 'detach' => false, # don't default to detaching the server + 'detach' => false, # default to not detaching the server 'show_drafts' => nil, 'limit_posts' => 0, 'lsi' => false,