Class: Jekyll::Commands::Serve

### Home Classes Methods

### In Files

- lib/jekyll/commands/serve.rb

### Parent

Jekyll::Command

### Methods

- ::process

### Included Modules

- WEBrick

### Files

- LICENSE

### Class/Module Index

Quicksearch

- Jekyll
- Jekyll::Command
- Jekyll::Commands
- Jekyll::Commands::Build
- Jekyll::Commands::Doctor
- Jekyll::Commands::New
- Jekyll::Commands::Serve
- Jekyll::Configuration
- Jekyll::Converter
- Jekyll::Converters
- Jekyll::Converters::Identity
- Jekyll::Converters::Markdown
- Jekyll::Converters::Markdown::KramdownParser
- Jekyll::Converters::Markdown::MarukuParser
- Jekyll::Converters::Markdown::RDiscountParser
- Jekyll::Converters::Markdown::RedcarpetParser
- Jekyll::Converters::Markdown::RedcarpetParser::CommonMethods
- Jekyll::Converters::Markdown::RedcarpetParser::WithPygments
- Jekyll::Converters::Markdown::RedcarpetParser::WithoutPygments
- Jekyll::Converters::Textile
- Jekyll::Convertible
- Jekyll::Deprecator
- Jekyll::Draft
- Jekyll::Excerpt
- Jekyll::FatalException
- Jekyll::Filters
- Jekyll::Generator
- Jekyll::Generators
- Jekyll::Generators::Pagination
- Jekyll::GistTag
- Jekyll::Layout
- Jekyll::Page
- Jekyll::Pager
- Jekyll::Plugin
- Jekyll::Post
- Jekyll::RelatedPosts
- Jekyll::Site
- Jekyll::Site::Cleaner
- Jekyll::StaticFile
- Jekyll::Stevenson
- Jekyll::Tags
- Jekyll::Tags::HighlightBlock
- Jekyll::Tags::IncludeTag
- Jekyll::Tags::PostComparer
- Jekyll::Tags::PostUrl
- Jekyll::URL
- Date
- Enumerable
- Hash
- Object

No matching classes.

# Jekyll::Commands::Serve

### Public Class Methods

process(options) click to toggle source

    # File lib/jekyll/commands/serve.rb, line 4
    def self.process(options)
      require 'webrick'
      include WEBrick

      destination = options['destination']

      FileUtils.mkdir_p(destination)

      mime_types_file = File.expand_path('../mime.types', File.dirname(__FILE__))
      mime_types = WEBrick::HTTPUtils::load_mime_types(mime_types_file)

      # recreate NondisclosureName under utf-8 circumstance
      fh_option = WEBrick::Config::FileHandler
      fh_option[:NondisclosureName] = ['.ht*','~*']

      s = HTTPServer.new(
        :Port => options['port'],
        :BindAddress => options['host'],
        :MimeTypes => mime_types
      )

      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()
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.