hx 0.20.0 → 0.21.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.
- data/VERSION +1 -1
- data/lib/hx/cli.rb +14 -9
- metadata +3 -3
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.
|
|
1
|
+
0.21.0
|
data/lib/hx/cli.rb
CHANGED
|
@@ -27,6 +27,7 @@ require 'optparse'
|
|
|
27
27
|
require 'pathname'
|
|
28
28
|
require 'tempfile'
|
|
29
29
|
require 'webrick'
|
|
30
|
+
require 'thread'
|
|
30
31
|
require 'rack'
|
|
31
32
|
require 'rack/mock'
|
|
32
33
|
require 'rack/handler/webrick'
|
|
@@ -107,21 +108,25 @@ def self.cmd_serve(site, port=nil)
|
|
|
107
108
|
server.logger.info "Serving on #{base_url}"
|
|
108
109
|
|
|
109
110
|
config_file = site.options[:config_file]
|
|
110
|
-
|
|
111
|
+
|
|
112
|
+
reload_lock = Mutex.new
|
|
111
113
|
site_app = nil
|
|
114
|
+
mtime = nil
|
|
112
115
|
|
|
113
116
|
app = Proc.new { |env|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
117
|
+
reload_lock.synchronize {
|
|
118
|
+
unless File.mtime(config_file) == mtime
|
|
119
|
+
# reload the site/config, folding in the new base URL
|
|
120
|
+
site = Hx::Site.load_file(config_file, :base_url => base_url)
|
|
121
|
+
mtime = File.mtime(config_file)
|
|
122
|
+
site_app = Hx::Rack::Application.new(site, site.options)
|
|
123
|
+
end
|
|
124
|
+
site_app
|
|
125
|
+
}.call(env)
|
|
121
126
|
}
|
|
122
127
|
|
|
123
128
|
# force application load
|
|
124
|
-
Rack::MockRequest.new(app).get("/")
|
|
129
|
+
::Rack::MockRequest.new(app).get("/")
|
|
125
130
|
|
|
126
131
|
server.mount('/', ::Rack::Handler::WEBrick, app)
|
|
127
132
|
%w(INT TERM).each { |s| trap(s) { server.shutdown } }
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: hx
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
hash:
|
|
4
|
+
hash: 75
|
|
5
5
|
prerelease: false
|
|
6
6
|
segments:
|
|
7
7
|
- 0
|
|
8
|
-
-
|
|
8
|
+
- 21
|
|
9
9
|
- 0
|
|
10
|
-
version: 0.
|
|
10
|
+
version: 0.21.0
|
|
11
11
|
platform: ruby
|
|
12
12
|
authors:
|
|
13
13
|
- MenTaLguY
|