guard-falcon 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/guard/falcon.rb +8 -59
- data/lib/guard/falcon/controller.rb +100 -0
- data/lib/guard/falcon/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ca8f7786cc49b12b390f9dc881dd08bb17c11a52
|
4
|
+
data.tar.gz: bc9e3180f55c5ccd22f7ebf1324983c1832cbd51
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 68b790dc399be8fa42a53543b196f786c14a75b100a86fbd4599bec61cda6931f05dbf7e874d7d5ca440d8e3c70d9492f4120b16a2918180db6b91f555e08e35
|
7
|
+
data.tar.gz: b3f5b549ebc6bd313a6c0795cee8398e8d1427f75cb20de9b59126fb0a8d8991bc95bfbd410ee3a6d48e103eba8971883922170b775a2b8f516cec9caffe1359
|
data/lib/guard/falcon.rb
CHANGED
@@ -18,68 +18,17 @@
|
|
18
18
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
19
|
# THE SOFTWARE.
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
require 'rack/builder'
|
24
|
-
require 'rack/server'
|
25
|
-
|
26
|
-
require 'async/container'
|
27
|
-
require "falcon/server"
|
21
|
+
require_relative 'falcon/controller'
|
28
22
|
|
29
23
|
module Guard
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
def self.default_env
|
34
|
-
ENV.fetch('RACK_ENV', 'development')
|
35
|
-
end
|
36
|
-
|
37
|
-
DEFAULT_OPTIONS = {
|
38
|
-
:bind => "tcp://localhost:9000",
|
39
|
-
:environment => default_env,
|
40
|
-
:config => 'config.ru',
|
41
|
-
}
|
42
|
-
|
43
|
-
def initialize(**options)
|
44
|
-
super
|
45
|
-
|
46
|
-
@options = DEFAULT_OPTIONS.merge(options)
|
47
|
-
@container = nil
|
48
|
-
end
|
49
|
-
|
50
|
-
def run_server
|
51
|
-
app, options = Rack::Builder.parse_file(@options[:config])
|
52
|
-
|
53
|
-
UI.info("Starting HTTP server on #{@options[:bind]}.")
|
54
|
-
|
55
|
-
Async::Container::Threaded.new(concurrency: 2) do
|
56
|
-
server = ::Falcon::Server.new(app, [
|
57
|
-
Async::IO::Address.parse(@options[:bind], reuse_port: true)
|
58
|
-
])
|
59
|
-
|
60
|
-
server.run
|
61
|
-
end
|
62
|
-
rescue
|
63
|
-
|
64
|
-
return nil
|
24
|
+
module Falcon
|
25
|
+
def self.new(*args)
|
26
|
+
Controller.new(*args)
|
65
27
|
end
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
def reload
|
72
|
-
stop
|
73
|
-
start
|
74
|
-
end
|
75
|
-
|
76
|
-
def stop
|
77
|
-
@container.stop
|
78
|
-
@container = nil
|
79
|
-
end
|
80
|
-
|
81
|
-
def run_on_change(paths)
|
82
|
-
reload
|
28
|
+
|
29
|
+
# Workaround for https://github.com/guard/guard/pull/872
|
30
|
+
def self.superclass
|
31
|
+
nil
|
83
32
|
end
|
84
33
|
end
|
85
34
|
end
|
@@ -0,0 +1,100 @@
|
|
1
|
+
# Copyright, 2017, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
# of this software and associated documentation files (the "Software"), to deal
|
5
|
+
# in the Software without restriction, including without limitation the rights
|
6
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
# copies of the Software, and to permit persons to whom the Software is
|
8
|
+
# furnished to do so, subject to the following conditions:
|
9
|
+
#
|
10
|
+
# The above copyright notice and this permission notice shall be included in
|
11
|
+
# all copies or substantial portions of the Software.
|
12
|
+
#
|
13
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
# THE SOFTWARE.
|
20
|
+
|
21
|
+
require 'guard/compat/plugin'
|
22
|
+
|
23
|
+
require 'rack/builder'
|
24
|
+
require 'rack/server'
|
25
|
+
|
26
|
+
require 'async/container/forked'
|
27
|
+
require 'falcon/server'
|
28
|
+
|
29
|
+
module Guard
|
30
|
+
module Falcon
|
31
|
+
class Controller < Plugin
|
32
|
+
def self.default_env
|
33
|
+
ENV.fetch('RACK_ENV', 'development')
|
34
|
+
end
|
35
|
+
|
36
|
+
DEFAULT_OPTIONS = {
|
37
|
+
:bind => "tcp://localhost:9000",
|
38
|
+
:environment => default_env,
|
39
|
+
:config => 'config.ru',
|
40
|
+
}
|
41
|
+
|
42
|
+
def initialize(**options)
|
43
|
+
super
|
44
|
+
|
45
|
+
@options = DEFAULT_OPTIONS.merge(options)
|
46
|
+
@container = nil
|
47
|
+
end
|
48
|
+
|
49
|
+
# As discussed in https://github.com/guard/guard/issues/713
|
50
|
+
def logger
|
51
|
+
Compat::UI
|
52
|
+
end
|
53
|
+
|
54
|
+
def run_server
|
55
|
+
begin
|
56
|
+
app, options = Rack::Builder.parse_file(@options[:config])
|
57
|
+
rescue
|
58
|
+
logger.error "Failed to load #{@options[:config]}: #{$!}"
|
59
|
+
logger.error $!.backtrace
|
60
|
+
end
|
61
|
+
|
62
|
+
logger.info("Starting Falcon HTTP server on #{@options[:bind]}.")
|
63
|
+
|
64
|
+
Async::Container::Forked.new(concurrency: 2) do
|
65
|
+
server = ::Falcon::Server.new(app, [
|
66
|
+
Async::IO::Address.parse(@options[:bind], reuse_port: true)
|
67
|
+
])
|
68
|
+
|
69
|
+
Process.setproctitle "Falcon HTTP #{@options[:bind]}"
|
70
|
+
|
71
|
+
server.run
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def start
|
76
|
+
@container = run_server
|
77
|
+
end
|
78
|
+
|
79
|
+
def running?
|
80
|
+
!@container.nil?
|
81
|
+
end
|
82
|
+
|
83
|
+
def reload
|
84
|
+
stop
|
85
|
+
start
|
86
|
+
end
|
87
|
+
|
88
|
+
def stop
|
89
|
+
if @container
|
90
|
+
@container.stop
|
91
|
+
@container = nil
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
def run_on_change(paths)
|
96
|
+
reload
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
data/lib/guard/falcon/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: guard-falcon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
@@ -109,6 +109,7 @@ files:
|
|
109
109
|
- Rakefile
|
110
110
|
- guard-falcon.gemspec
|
111
111
|
- lib/guard/falcon.rb
|
112
|
+
- lib/guard/falcon/controller.rb
|
112
113
|
- lib/guard/falcon/templates/Guardfile
|
113
114
|
- lib/guard/falcon/version.rb
|
114
115
|
homepage: https://github.com/socketry/guard-falcon
|