Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Include simple rack-based HTTP server from Virginia
For tests we currently remove the generated Gemfile so that the app boots with the version of Adhearsion under test. The generated Gemfile contains sinatra such that the default rack app will work. In order for the app to boot with the sample Rack config, we must include Sinatra at the project Gemfile level.
- Loading branch information
1 parent
4b9846a
commit 579d1c8
Showing
10 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
source 'https://rubygems.org' | ||
|
||
gemspec | ||
|
||
gem 'sinatra', require: nil |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
require 'sinatra' | ||
|
||
get '/' do | ||
'Hello world!' | ||
end | ||
|
||
run Sinatra::Application |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# encoding: utf-8 | ||
|
||
require 'reel' | ||
require 'reel/rack' | ||
|
||
module Adhearsion | ||
# @private | ||
class HTTPServer | ||
def self.start | ||
config = Adhearsion.config.platform.http | ||
|
||
return unless config.enable | ||
|
||
rackup = File.join(Adhearsion.root, config.rackup) | ||
unless File.exists?(rackup) | ||
logger.error "Cannot start HTTP server because the Rack configuration does not exist at #{rackup}" | ||
return | ||
end | ||
|
||
app, options = ::Rack::Builder.parse_file rackup | ||
options = { | ||
Host: config.host, | ||
Port: config.port, | ||
}.merge(options) | ||
|
||
app = Rack::CommonLogger.new(app, logger) | ||
|
||
logger.info "Starting HTTP server listening on #{config.host}:#{config.port}" | ||
|
||
supervisor = ::Reel::Rack::Server.supervise_as(:ahn_http_server, app, options) | ||
|
||
Adhearsion::Events.register_callback :shutdown do | ||
supervisor.terminate | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters