Skip to content

Commit

Permalink
Add some extra debugging.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Jun 26, 2024
1 parent 68bf30c commit 26d34d9
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 7 deletions.
1 change: 0 additions & 1 deletion guard-falcon.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ Gem::Specification.new do |spec|

spec.required_ruby_version = ">= 3.1"

spec.add_dependency "async-container", "~> 0.16"
spec.add_dependency "console", "~> 1.0"
spec.add_dependency "falcon", "~> 0.35"
spec.add_dependency "guard"
Expand Down
24 changes: 20 additions & 4 deletions lib/guard/falcon/plugin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
require 'guard/compat/plugin'

require 'falcon'
require 'falcon/endpoint'
require 'falcon/environment/rackup'
require 'falcon/environment/server'
require 'async/service'
Expand All @@ -15,11 +16,23 @@
module Guard
module Falcon
class Plugin < Guard::Plugin
module Environment
include ::Falcon::Environment::Server
include ::Falcon::Environment::Rackup

# The upstream endpoint that will handle incoming requests.
# @returns [Async::HTTP::Endpoint]
def endpoint
::Falcon::Endpoint.parse(url).with(
reuse_address: true,
# reuse_port: true,
timeout: timeout,
)
end
end

def self.default_environment(**options)
Async::Service::Environment.new(::Falcon::Environment::Server).with(
::Falcon::Environment::Rackup,
**options
)
Async::Service::Environment.new(Environment).with(**options)
end

def initialize(**options)
Expand All @@ -46,6 +59,7 @@ def initialize(**options)
end

def start
Console.info(self, "Starting...")
@controller.start
end

Expand All @@ -54,10 +68,12 @@ def running?
end

def reload
Console.info(self, "Reloading...")
@controller.restart
end

def stop
Console.info(self, "Stopping...")
@controller.stop
end

Expand Down
5 changes: 5 additions & 0 deletions test/guard/falcon/Guardfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
require 'guard/falcon'

guard "falcon", count: 1, url: "http://0.0.0.0:2300" do
watch('config.ru')
end
5 changes: 3 additions & 2 deletions test/guard/falcon/config.ru
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@

run lambda {|env| [200, {}, []]}
run do |env|
[200, {}, []]
end

0 comments on commit 26d34d9

Please sign in to comment.