Skip to content

Commit

Permalink
Update dependencies. Add support for explicit endpoint.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed May 7, 2018
1 parent bfdd88f commit 0e6f9cc
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion guard-falcon.gemspec
Expand Up @@ -16,7 +16,7 @@ Gem::Specification.new do |spec|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
spec.require_paths = ["lib"]

spec.add_dependency("falcon", "~> 0.14.0")
spec.add_dependency("falcon", "~> 0.15.0")

spec.add_dependency("guard")
spec.add_dependency("guard-compat", "~> 1.2")
Expand Down
19 changes: 13 additions & 6 deletions lib/guard/falcon/controller.rb
Expand Up @@ -26,6 +26,7 @@
require 'async/container/forked'

require 'async/io/host_endpoint'
require 'async/http/url_endpoint'

require 'falcon/server'
require 'falcon/adapters/rack'
Expand All @@ -34,8 +35,6 @@ module Guard
module Falcon
class Controller < Plugin
DEFAULT_OPTIONS = {
port: 9292,
host: 'localhost',
config: 'config.ru',
concurrency: 2,
}
Expand All @@ -60,14 +59,22 @@ def run_server
logger.error $!.backtrace
end

server_address = Async::IO::Endpoint.tcp(@options[:host], @options[:port], reuse_port: true)
# Support existing use cases where only port: is specified.
if @options[:endpoint]
endpoint = @options[:endpoint]
elsif port = @options[:port]
host = @options[:host] || 'localhost'
endpoint = Async::IO::Endpoint.tcp(host, port, reuse_port: true)
else
endpoint = Async::HTTP::URLEndpoint.parse("http://localhost:9292", reuse_port: true)
end

logger.info("Starting Falcon HTTP server on #{server_address}.")
logger.info("Starting Falcon HTTP server on #{endpoint}.")

Async::Container::Forked.new(concurrency: @options[:concurrency]) do
server = ::Falcon::Server.new(::Falcon::Adapters::Rack.new(app), server_address)
server = ::Falcon::Server.new(::Falcon::Adapters::Rack.new(app), endpoint)

Process.setproctitle "Guard::Falcon HTTP Server #{@options[:bind]}"
Process.setproctitle "Guard::Falcon HTTP Server: #{endpoint}"

server.run
end
Expand Down
2 changes: 1 addition & 1 deletion lib/guard/falcon/version.rb
Expand Up @@ -20,6 +20,6 @@

module Guard
module Falcon
VERSION = "0.7.0"
VERSION = "0.8.0"
end
end

0 comments on commit 0e6f9cc

Please sign in to comment.