Skip to content

Commit

Permalink
adding a rake task to start up the server
Browse files Browse the repository at this point in the history
  • Loading branch information
tenderlove committed Mar 26, 2012
1 parent 01b2259 commit af558ba
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
15 changes: 15 additions & 0 deletions lib/spectacular/rake.rb
@@ -0,0 +1,15 @@
require 'rake'
require 'spectacular/server'

namespace :spectacular do
desc 'start the spectacular server'
task :server do
server = WEBrick::HTTPServer.new :Port => 8080, :OutputBufferSize => 256

server.mount '/', Spectacular::Server::Index
server.mount '/events.json', Spectacular::Server::Events

trap('INT') { server.shutdown }
server.start
end
end
12 changes: 0 additions & 12 deletions lib/spectacular/server.rb
Expand Up @@ -2,8 +2,6 @@
require 'spectacular'
require 'json'

Thread.abort_on_exception = true

module Spectacular
module Server
dir = File.dirname __FILE__
Expand Down Expand Up @@ -53,13 +51,3 @@ def do_GET request, response
end
end
end

if $0 == __FILE__
server = WEBrick::HTTPServer.new :Port => 8080, :OutputBufferSize => 256

server.mount '/', Spectacular::Server::Index
server.mount '/events.json', Spectacular::Server::Events

trap('INT') { server.shutdown }
server.start
end

0 comments on commit af558ba

Please sign in to comment.