Class: Jekyll::Commands::Serve
- Inherits:
-
Jekyll::Command
- Object
- Jekyll::Command
- Jekyll::Commands::Serve
- Defined in:
- lib/jekyll/commands/serve.rb,
lib/jekyll/commands/serve/servlet.rb,
lib/jekyll/commands/serve/websockets.rb,
lib/jekyll/commands/serve/live_reload_reactor.rb
Defined Under Namespace
Classes: BodyProcessor, HttpAwareConnection, LiveReloadReactor, Servlet, SkipAnalyzer
Constant Summary collapse
- COMMAND_OPTIONS =
{ "ssl_cert" => ["--ssl-cert [CERT]", "X.509 (SSL) certificate."], "host" => ["host", "-H", "--host [HOST]", "Host to bind to"], "open_url" => ["-o", "--open-url", "Launch your site in a browser"], "detach" => ["-B", "--detach", "Run the server in the background",], "ssl_key" => ["--ssl-key [KEY]", "X.509 (SSL) Private Key."], "port" => ["-P", "--port [PORT]", "Port to listen on"], "show_dir_listing" => ["--show-dir-listing", "Show a directory listing instead of loading " \ "your index file.",], "skip_initial_build" => ["skip_initial_build", "--skip-initial-build", "Skips the initial site build which occurs before " \ "the server is started.",], "livereload" => ["-l", "--livereload", "Use LiveReload to automatically refresh browsers",], "livereload_ignore" => ["--livereload-ignore ignore GLOB1[,GLOB2[,...]]", Array, "Files for LiveReload to ignore. " \ "Remember to quote the values so your shell " \ "won't expand them",], "livereload_min_delay" => ["--livereload-min-delay [SECONDS]", "Minimum reload delay",], "livereload_max_delay" => ["--livereload-max-delay [SECONDS]", "Maximum reload delay",], "livereload_port" => ["--livereload-port [PORT]", Integer, "Port for LiveReload to listen on",], }.freeze
- DIRECTORY_INDEX =
%w( index.htm index.html index.rhtml index.xht index.xhtml index.cgi index.xml index.json ).freeze
- LIVERELOAD_PORT =
35_729
- LIVERELOAD_DIR =
File.join(__dir__, "serve", "livereload_assets")
Class Attribute Summary collapse
-
.mutex ⇒ Object
readonly
Returns the value of attribute mutex.
-
.run_cond ⇒ Object
readonly
Returns the value of attribute run_cond.
-
.running ⇒ Object
(also: running?)
readonly
Returns the value of attribute running.
Class Method Summary collapse
Methods inherited from Jekyll::Command
add_build_options, configuration_from_options, inherited, process_site, process_with_graceful_fail, subclasses
Class Attribute Details
.mutex ⇒ Object (readonly)
Returns the value of attribute mutex.
58 59 60 |
# File 'lib/jekyll/commands/serve.rb', line 58 def mutex @mutex end |
.run_cond ⇒ Object (readonly)
Returns the value of attribute run_cond.
58 59 60 |
# File 'lib/jekyll/commands/serve.rb', line 58 def run_cond @run_cond end |
.running ⇒ Object (readonly) Also known as: running?
Returns the value of attribute running.
58 59 60 |
# File 'lib/jekyll/commands/serve.rb', line 58 def running @running end |
Class Method Details
.init_with_program(prog) ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/jekyll/commands/serve.rb', line 61 def init_with_program(prog) prog.command(:serve) do |cmd| cmd.description "Serve your site locally" cmd.syntax "serve [options]" cmd.alias :server cmd.alias :s (cmd) COMMAND_OPTIONS.each do |key, val| cmd.option key, *val end cmd.action do |_, opts| opts["livereload_port"] ||= LIVERELOAD_PORT opts["serving"] = true opts["watch"] = true unless opts.key?("watch") # Set the reactor to nil so any old reactor will be GCed. # We can't unregister a hook so while running tests we don't want to # inadvertently keep using a reactor created by a previous test. @reload_reactor = nil config = (opts) config["url"] = default_url(config) if Jekyll.env == "development" process_with_graceful_fail(cmd, config, Build, Serve) end end end |
.process(opts) ⇒ Object
93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/jekyll/commands/serve.rb', line 93 def process(opts) opts = (opts) destination = opts["destination"] if opts["livereload"] (opts) register_reload_hooks(opts) end setup(destination) start_up_webrick(opts, destination) end |
.shutdown ⇒ Object
105 106 107 |
# File 'lib/jekyll/commands/serve.rb', line 105 def shutdown @server.shutdown if running? end |