Class: QuickServe::Server
- Inherits:
-
Object
- Object
- QuickServe::Server
- Defined in:
- lib/quick_serve/server.rb
Instance Method Summary collapse
-
#initialize ⇒ Server
constructor
A new instance of Server.
- #start ⇒ Object
Constructor Details
#initialize ⇒ Server
Returns a new instance of Server.
4 5 6 7 |
# File 'lib/quick_serve/server.rb', line 4 def initialize @options = { :dir => Dir.pwd, :port => 5000, :host => '0.0.0.0', :deamon => false, :url => nil } parse end |
Instance Method Details
#start ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/quick_serve/server.rb', line 9 def start if @options[:url] puts "quick_serve: running in snapshot mode using #{@options[:url]} as source" else puts "quick_serve: mongrel running on port #{@options[:port]} with docroot in #{@options[:dir]}" end begin if @options[:deamon] pid = fork do $stderr, $stdout = StringIO.new, StringIO.new serve end File.open(pidfile, 'w') {|f| f.write(pid) } else serve end rescue Errno::EADDRINUSE puts "quick_serve: port #{@options[:port]} is used by another process. Please specify other port using the -p option" end end |