adding detachment functionality

This commit is contained in:
ddavison 2013-08-21 20:53:01 +00:00
parent d40e7942c5
commit 4e52869f0f
2 changed files with 12 additions and 3 deletions

View File

@ -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'

View File

@ -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