Class: Gemstar::Commands::Server
- Defined in:
- lib/gemstar/commands/server.rb
Constant Summary collapse
- DEFAULT_BIND =
"127.0.0.1"- DEFAULT_PORT =
2112- RELOAD_ENV_VAR =
"GEMSTAR_RELOAD_ACTIVE"- RELOAD_GLOB =
"{lib/**/*.rb,lib/gemstar/web/templates/**/*,bin/gemstar,README.md}"- RELOAD_DIRS =
%w[lib bin].freeze
Instance Attribute Summary collapse
-
#bind ⇒ Object
readonly
Returns the value of attribute bind.
-
#explicit_port ⇒ Object
readonly
Returns the value of attribute explicit_port.
-
#open_browser ⇒ Object
readonly
Returns the value of attribute open_browser.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
-
#project_inputs ⇒ Object
readonly
Returns the value of attribute project_inputs.
-
#reload ⇒ Object
readonly
Returns the value of attribute reload.
Instance Method Summary collapse
-
#initialize(options) ⇒ Server
constructor
A new instance of Server.
- #run ⇒ Object
Constructor Details
#initialize(options) ⇒ Server
Returns a new instance of Server.
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/gemstar/commands/server.rb', line 22 def initialize() super @bind = [:bind] || DEFAULT_BIND @explicit_port = ![:port].nil? @port = ([:port] || DEFAULT_PORT).to_i @project_inputs = normalize_project_inputs([:project]) @reload = [:reload] @open_browser = [:open] end |
Instance Attribute Details
#bind ⇒ Object (readonly)
Returns the value of attribute bind.
15 16 17 |
# File 'lib/gemstar/commands/server.rb', line 15 def bind @bind end |
#explicit_port ⇒ Object (readonly)
Returns the value of attribute explicit_port.
20 21 22 |
# File 'lib/gemstar/commands/server.rb', line 20 def explicit_port @explicit_port end |
#open_browser ⇒ Object (readonly)
Returns the value of attribute open_browser.
19 20 21 |
# File 'lib/gemstar/commands/server.rb', line 19 def open_browser @open_browser end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
16 17 18 |
# File 'lib/gemstar/commands/server.rb', line 16 def port @port end |
#project_inputs ⇒ Object (readonly)
Returns the value of attribute project_inputs.
17 18 19 |
# File 'lib/gemstar/commands/server.rb', line 17 def project_inputs @project_inputs end |
#reload ⇒ Object (readonly)
Returns the value of attribute reload.
18 19 20 |
# File 'lib/gemstar/commands/server.rb', line 18 def reload @reload end |
Instance Method Details
#run ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/gemstar/commands/server.rb', line 33 def run restart_with_rerun if reload_requested? require "rackup" require "webrick" require "gemstar/request_logger" require "gemstar/webrick_logger" require "gemstar/web/app" Gemstar::Config.ensure_home_directory! @port = resolve_port projects = load_projects log_loaded_projects(projects) cache_warmer = build_cache_warmer app = Gemstar::Web::App.build(projects: projects, config_home: Gemstar::Config.home_directory, cache_warmer: cache_warmer) app = Gemstar::RequestLogger.new(app, io: $stderr) if debug_request_logging? puts "Gemstar server listening on http://#{bind}:#{port}" puts "Config home: #{Gemstar::Config.home_directory}" Rackup::Server.start( app: app, server: "webrick", Host: bind, Port: port, AccessLog: [], Logger: Gemstar::WEBrickLogger.new($stderr, WEBrick::BasicLog::INFO), StartCallback: server_start_callback(projects, cache_warmer) ) end |