Module: Proton::Server
- Extended by:
- CLI::Helpers
- Defined in:
- lib/proton/server.rb,
lib/proton/server.rb,
lib/proton/server.rb
Defined Under Namespace
Modules: PageHelpers
Class Method Summary collapse
-
.options ⇒ Object
Available options: :last_modified – timestamp for all files.
- .quit!(server, handler_name) ⇒ Object
- .rack_handler ⇒ Object
-
.run!(options = {}) ⇒ Object
:Host, :Port.
Methods included from CLI::Helpers
gem_name, no_project, other_tasks, project, project?, say_error, say_info, say_status, show_help_for, show_needed_gem, tasks_for
Class Method Details
.options ⇒ Object
Available options:
:last_modified -- timestamp for all files
85 86 87 |
# File 'lib/proton/server.rb', line 85 def self. @options ||= Hash.new end |
.quit!(server, handler_name) ⇒ Object
109 110 111 112 113 114 115 |
# File 'lib/proton/server.rb', line 109 def self.quit!(server, handler_name) # Use Thin's hard #stop! if available, otherwise just #stop. server.respond_to?(:stop!) ? server.stop! : server.stop puts say_status '==>', "Exiting..." unless handler_name =~/cgi/i puts end |
.rack_handler ⇒ Object
117 118 119 120 121 122 123 124 125 |
# File 'lib/proton/server.rb', line 117 def self.rack_handler %w(thin mongrel webrick).each do |svr| begin return Rack::Handler.get(svr) rescue LoadError rescue NameError end end end |
.run!(options = {}) ⇒ Object
:Host, :Port
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/proton/server.rb', line 90 def self.run!(={}) self..merge handler = rack_handler or return false handler_name = handler.name.gsub(/.*::/, '') url = "http://#{[:Host]}:#{[:Port]}/" handler.run self, do |server| puts say_status '==>', "Proton server has now started (via #{handler_name})." say_info "Point your browser to: #{url}" puts [:INT, :TERM].each { |sig| trap(sig) { quit!(server, handler_name) } } end rescue Errno::EADDRINUSE => e say_error "Someone is already performing on port #{port}!" end |