From 1167c8e1230a4bf216628f5c21d03369034f1364 Mon Sep 17 00:00:00 2001 From: "Steven G. Harms" Date: Sun, 2 Aug 2015 11:10:28 -0700 Subject: [PATCH] Update Rakefile to support hostname specification While the typical case is to support `localhost` on a laptop where DNS routing is not used, assumption of this name is incompatible for those with a remote-system / mainframe-esque work environment. This change surfaces to users that this is changeable in case they have the ability to change this and use name resolution (if they so desire). --- Rakefile | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Rakefile b/Rakefile index 9367ea1eae4..1ba3471b211 100644 --- a/Rakefile +++ b/Rakefile @@ -25,7 +25,8 @@ posts_dir = "_posts" # directory for blog files themes_dir = ".themes" # directory for blog files new_post_ext = "markdown" # default new post file extension when using the new_post task new_page_ext = "markdown" # default new page file extension when using the new_page task -server_port = "4000" # port for preview server eg. localhost:4000 +server_host = "localhost" # default host name for the preview server to use +server_port = "4000" # port for preview server eg. #{server_host}:4000 if (/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM) != nil puts '## Set the codepage to 65001 for Windows machines' @@ -79,11 +80,11 @@ end desc "preview the site in a web browser" task :preview do raise "### You haven't set anything up yet. First run `rake install` to set up an Octopress theme." unless File.directory?(source_dir) - puts "Starting to watch source with Jekyll and Compass. Starting Rack on port #{server_port}" + puts "Starting to watch source with Jekyll and Compass. Starting Rack on port #{server_host}:#{server_port}" system "compass compile --css-dir #{source_dir}/stylesheets" unless File.exist?("#{source_dir}/stylesheets/screen.css") jekyllPid = Process.spawn({"OCTOPRESS_ENV"=>"preview"}, "jekyll build --watch") compassPid = Process.spawn("compass watch") - rackupPid = Process.spawn("rackup --port #{server_port}") + rackupPid = Process.spawn("rackup --port #{server_port} -o #{server_host}") trap("INT") { [jekyllPid, compassPid, rackupPid].each { |pid| Process.kill(9, pid) rescue Errno::ESRCH }