rack-handlers 0.7.2 → 0.7.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +18 -0
- data/CHANGES.md +4 -0
- data/Gemfile +15 -0
- data/README.md +2 -1
- data/Rakefile +1 -2
- data/config.ru +4 -0
- data/config/environment.rb +0 -0
- data/lib/rack/handler/rails-server.rb +1 -1
- data/lib/rack/handler/unicorn.rb +9 -1
- data/rack-handlers.gemspec +42 -30
- data/script/config.ru +0 -0
- data/script/rails +17 -0
- data/task/README.md +54 -0
- data/task/gemgem.rb +119 -67
- data/test/shared.rb +36 -0
- data/test/test_basic.rb +29 -0
- data/test/test_rails.rb +20 -0
- metadata +16 -5
- data/task/.gitignore +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e816e057dcaad84c8d013e3240650e941eb3075e
|
4
|
+
data.tar.gz: 0a870189ac4682e159c2925d00876282fcd598f7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 36bdd8a177ce91cc97b929651c5fa3f1a6a1ce356c04ed6d2047b23bafafb8a1969751f9acf14fbb2c78a468e0fe9eb497de4b53a58bb3c32814d6b8bc536310
|
7
|
+
data.tar.gz: fee8bbd4f495b838b9375f8091d230befeb653677ccfb29064fc8c0bc5f25534e3672117b4cb243a8a3af8c9ed19bb09b3cfcb504b89e527a49bc92cfe0222f4
|
data/.travis.yml
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
sudo: true
|
2
|
+
language: ruby
|
3
|
+
rvm:
|
4
|
+
- 2.1
|
5
|
+
- 2.2
|
6
|
+
- 2.3.0
|
7
|
+
- rbx
|
8
|
+
- jruby-9
|
9
|
+
|
10
|
+
before_install:
|
11
|
+
- rvm get head
|
12
|
+
- rvm reload
|
13
|
+
- rvm use --install $TRAVIS_RUBY_VERSION --binary --latest
|
14
|
+
install:
|
15
|
+
- gem install bundler
|
16
|
+
- bundle install --retry=3
|
17
|
+
- gem install yahns zbatery rainbows unicorn puma thin torquebox trinidad || true
|
18
|
+
script: 'rake test'
|
data/CHANGES.md
CHANGED
data/Gemfile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
|
2
|
+
source 'https://rubygems.org'
|
3
|
+
|
4
|
+
gemspec
|
5
|
+
|
6
|
+
gem 'rake'
|
7
|
+
gem 'pork'
|
8
|
+
|
9
|
+
gem 'simplecov', :require => false if ENV['COV']
|
10
|
+
gem 'coveralls', :require => false if ENV['CI']
|
11
|
+
|
12
|
+
platforms :rbx do
|
13
|
+
gem 'rubysl-singleton' # used in rake
|
14
|
+
gem 'rubysl-readline' # we need readline extension
|
15
|
+
end
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# rack-handlers
|
1
|
+
# rack-handlers [![Build Status](https://secure.travis-ci.org/godfat/rack-handlers.png?branch=master)](http://travis-ci.org/godfat/rack-handlers) [![Coverage Status](https://coveralls.io/repos/godfat/rack-handlers/badge.png)](https://coveralls.io/r/godfat/rack-handlers)
|
2
2
|
|
3
3
|
by Lin Jen-Shin ([godfat](http://godfat.org))
|
4
4
|
|
@@ -54,6 +54,7 @@ For people who likes to run `rails s`!
|
|
54
54
|
|
55
55
|
## CONTRIBUTORS:
|
56
56
|
|
57
|
+
* John Goulah (@jgoulah)
|
57
58
|
* Lin Jen-Shin (@godfat)
|
58
59
|
|
59
60
|
## LICENSE:
|
data/Rakefile
CHANGED
data/config.ru
ADDED
File without changes
|
data/lib/rack/handler/unicorn.rb
CHANGED
@@ -9,7 +9,7 @@ class Rack::Handler::Unicorn
|
|
9
9
|
|
10
10
|
def self.run app, opts
|
11
11
|
server_name = name[/::(\w+)$/, 1].downcase
|
12
|
-
config_path = "#{
|
12
|
+
config_path = "#{config_dir(opts)}/config/#{server_name}.rb"
|
13
13
|
config_file = config_path if File.exist?(config_path)
|
14
14
|
|
15
15
|
server = initialize_server(app, opts, config_file)
|
@@ -19,6 +19,14 @@ class Rack::Handler::Unicorn
|
|
19
19
|
server.start.join
|
20
20
|
end
|
21
21
|
|
22
|
+
def self.config_dir opts
|
23
|
+
if opts[:config]
|
24
|
+
File.dirname(opts[:config])
|
25
|
+
else
|
26
|
+
'.'
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
22
30
|
def self.initialize_server app, opts, config_file
|
23
31
|
server_class.new(app, :listeners => "#{opts[:Host]}:#{opts[:Port]}",
|
24
32
|
:config_file => config_file)
|
data/rack-handlers.gemspec
CHANGED
@@ -1,45 +1,57 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
# stub: rack-handlers 0.7.
|
2
|
+
# stub: rack-handlers 0.7.3 ruby lib
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
|
-
s.name = "rack-handlers"
|
6
|
-
s.version = "0.7.
|
5
|
+
s.name = "rack-handlers".freeze
|
6
|
+
s.version = "0.7.3"
|
7
7
|
|
8
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
9
|
-
s.require_paths = ["lib"]
|
10
|
-
s.authors = ["Lin Jen-Shin (godfat)"]
|
11
|
-
s.date = "2016-
|
12
|
-
s.description = "Unicorn family Rack handlers for you. Mostly for `rails s`."
|
13
|
-
s.email = ["godfat (XD) godfat.org"]
|
8
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
9
|
+
s.require_paths = ["lib".freeze]
|
10
|
+
s.authors = ["Lin Jen-Shin (godfat)".freeze]
|
11
|
+
s.date = "2016-04-27"
|
12
|
+
s.description = "Unicorn family Rack handlers for you. Mostly for `rails s`.".freeze
|
13
|
+
s.email = ["godfat (XD) godfat.org".freeze]
|
14
14
|
s.files = [
|
15
|
-
".gitignore",
|
16
|
-
".gitmodules",
|
17
|
-
"
|
18
|
-
"
|
19
|
-
"
|
20
|
-
"
|
21
|
-
"
|
22
|
-
"
|
23
|
-
"
|
24
|
-
"lib/rack
|
25
|
-
"lib/rack/handler/
|
26
|
-
"rack
|
27
|
-
"
|
28
|
-
"
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
15
|
+
".gitignore".freeze,
|
16
|
+
".gitmodules".freeze,
|
17
|
+
".travis.yml".freeze,
|
18
|
+
"CHANGES.md".freeze,
|
19
|
+
"Gemfile".freeze,
|
20
|
+
"README.md".freeze,
|
21
|
+
"Rakefile".freeze,
|
22
|
+
"config.ru".freeze,
|
23
|
+
"config/environment.rb".freeze,
|
24
|
+
"lib/rack-handlers.rb".freeze,
|
25
|
+
"lib/rack/handler/rails-server.rb".freeze,
|
26
|
+
"lib/rack/handler/rainbows.rb".freeze,
|
27
|
+
"lib/rack/handler/unicorn.rb".freeze,
|
28
|
+
"lib/rack/handler/yahns.rb".freeze,
|
29
|
+
"lib/rack/handler/zbatery.rb".freeze,
|
30
|
+
"rack-handlers.gemspec".freeze,
|
31
|
+
"script/config.ru".freeze,
|
32
|
+
"script/rails".freeze,
|
33
|
+
"task/README.md".freeze,
|
34
|
+
"task/gemgem.rb".freeze,
|
35
|
+
"test/shared.rb".freeze,
|
36
|
+
"test/test_basic.rb".freeze,
|
37
|
+
"test/test_rails.rb".freeze]
|
38
|
+
s.homepage = "https://github.com/godfat/rack-handlers".freeze
|
39
|
+
s.licenses = ["Apache License 2.0".freeze]
|
40
|
+
s.rubygems_version = "2.6.3".freeze
|
41
|
+
s.summary = "Unicorn family Rack handlers for you. Mostly for `rails s`.".freeze
|
42
|
+
s.test_files = [
|
43
|
+
"test/test_basic.rb".freeze,
|
44
|
+
"test/test_rails.rb".freeze]
|
33
45
|
|
34
46
|
if s.respond_to? :specification_version then
|
35
47
|
s.specification_version = 4
|
36
48
|
|
37
49
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
38
|
-
s.add_runtime_dependency(%q<rack
|
50
|
+
s.add_runtime_dependency(%q<rack>.freeze, [">= 0"])
|
39
51
|
else
|
40
|
-
s.add_dependency(%q<rack
|
52
|
+
s.add_dependency(%q<rack>.freeze, [">= 0"])
|
41
53
|
end
|
42
54
|
else
|
43
|
-
s.add_dependency(%q<rack
|
55
|
+
s.add_dependency(%q<rack>.freeze, [">= 0"])
|
44
56
|
end
|
45
57
|
end
|
data/script/config.ru
ADDED
File without changes
|
data/script/rails
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
|
2
|
+
require 'rails'
|
3
|
+
require 'logger'
|
4
|
+
|
5
|
+
APP_PATH = 'rails'
|
6
|
+
root = File.expand_path("#{__dir__}/..")
|
7
|
+
config = Rails::Application::Configuration.new
|
8
|
+
config.root = root
|
9
|
+
app = Class.new(Struct.new(:root, :config)) do
|
10
|
+
def call _
|
11
|
+
[200, {}, ["OK\n"]]
|
12
|
+
end
|
13
|
+
end.new(root, config)
|
14
|
+
Rails.application = app
|
15
|
+
Rails.logger = Logger.new(File.open(IO::NULL))
|
16
|
+
|
17
|
+
require 'rails/commands'
|
data/task/README.md
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
# Gemgem
|
2
|
+
|
3
|
+
## DESCRIPTION:
|
4
|
+
|
5
|
+
Provided tasks:
|
6
|
+
|
7
|
+
rake clean # Remove ignored files
|
8
|
+
rake gem:build # Build gem
|
9
|
+
rake gem:install # Install gem
|
10
|
+
rake gem:release # Release gem
|
11
|
+
rake gem:spec # Generate gemspec
|
12
|
+
rake test # Run tests in memory
|
13
|
+
|
14
|
+
## REQUIREMENTS:
|
15
|
+
|
16
|
+
* Tested with MRI (official CRuby) 1.9.3, 2.0.0, Rubinius and JRuby.
|
17
|
+
|
18
|
+
## INSTALLATION:
|
19
|
+
|
20
|
+
git submodule add git://github.com/godfat/gemgem.git task
|
21
|
+
|
22
|
+
And in Rakefile:
|
23
|
+
|
24
|
+
``` ruby
|
25
|
+
begin
|
26
|
+
require "#{dir = File.dirname(__FILE__)}/task/gemgem"
|
27
|
+
rescue LoadError
|
28
|
+
sh 'git submodule update --init'
|
29
|
+
exec Gem.ruby, '-S', $PROGRAM_NAME, *ARGV
|
30
|
+
end
|
31
|
+
|
32
|
+
Gemgem.init(dir) do |s|
|
33
|
+
s.name = 'your-gem'
|
34
|
+
s.version = '0.1.0'
|
35
|
+
end
|
36
|
+
```
|
37
|
+
|
38
|
+
## LICENSE:
|
39
|
+
|
40
|
+
Apache License 2.0
|
41
|
+
|
42
|
+
Copyright (c) 2011-2013, Lin Jen-Shin (godfat)
|
43
|
+
|
44
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
45
|
+
you may not use this file except in compliance with the License.
|
46
|
+
You may obtain a copy of the License at
|
47
|
+
|
48
|
+
<http://www.apache.org/licenses/LICENSE-2.0>
|
49
|
+
|
50
|
+
Unless required by applicable law or agreed to in writing, software
|
51
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
52
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
53
|
+
See the License for the specific language governing permissions and
|
54
|
+
limitations under the License.
|
data/task/gemgem.rb
CHANGED
@@ -34,10 +34,112 @@ module Gemgem
|
|
34
34
|
s.executables = bin_files
|
35
35
|
end
|
36
36
|
spec_create.call(spec)
|
37
|
-
spec.homepage
|
37
|
+
spec.homepage ||= "https://github.com/godfat/#{spec.name}"
|
38
38
|
self.spec = spec
|
39
39
|
end
|
40
40
|
|
41
|
+
def gem_install
|
42
|
+
require 'rubygems/commands/install_command'
|
43
|
+
# read ~/.gemrc
|
44
|
+
Gem.use_paths(Gem.configuration[:gemhome], Gem.configuration[:gempath])
|
45
|
+
Gem::Command.extra_args = Gem.configuration[:gem]
|
46
|
+
|
47
|
+
# setup install options
|
48
|
+
cmd = Gem::Commands::InstallCommand.new
|
49
|
+
cmd.handle_options([])
|
50
|
+
|
51
|
+
# install
|
52
|
+
install = Gem::Installer.new(gem_path, cmd.options)
|
53
|
+
install.install
|
54
|
+
puts "\e[35mGem installed: \e[33m#{strip_path(install.gem_dir)}\e[0m"
|
55
|
+
end
|
56
|
+
|
57
|
+
def gem_spec
|
58
|
+
create
|
59
|
+
write
|
60
|
+
end
|
61
|
+
|
62
|
+
def gem_build
|
63
|
+
require 'fileutils'
|
64
|
+
require 'rubygems/package'
|
65
|
+
gem = nil
|
66
|
+
Dir.chdir(dir) do
|
67
|
+
gem = Gem::Package.build(Gem::Specification.load(spec_path))
|
68
|
+
FileUtils.mkdir_p(pkg_dir)
|
69
|
+
FileUtils.mv(gem, pkg_dir) # gem is relative path, but might be ok
|
70
|
+
end
|
71
|
+
puts "\e[35mGem built: \e[33m#{strip_path("#{pkg_dir}/#{gem}")}\e[0m"
|
72
|
+
end
|
73
|
+
|
74
|
+
def gem_release
|
75
|
+
sh_git('tag', gem_tag)
|
76
|
+
sh_git('push')
|
77
|
+
sh_git('push', '--tags')
|
78
|
+
sh_gem('push', gem_path)
|
79
|
+
end
|
80
|
+
|
81
|
+
def gem_check
|
82
|
+
unless git('status', '--porcelain').empty?
|
83
|
+
puts("\e[35mWorking copy is not clean.\e[0m")
|
84
|
+
exit(3)
|
85
|
+
end
|
86
|
+
|
87
|
+
ver = spec.version.to_s
|
88
|
+
|
89
|
+
if ENV['VERSION'].nil?
|
90
|
+
puts("\e[35mExpected " \
|
91
|
+
"\e[33mVERSION\e[35m=\e[33m#{ver}\e[0m")
|
92
|
+
exit(1)
|
93
|
+
|
94
|
+
elsif ENV['VERSION'] != ver
|
95
|
+
puts("\e[35mExpected \e[33mVERSION\e[35m=\e[33m#{ver} " \
|
96
|
+
"\e[35mbut got\n " \
|
97
|
+
"\e[33mVERSION\e[35m=\e[33m#{ENV['VERSION']}\e[0m")
|
98
|
+
exit(2)
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
def test
|
103
|
+
return if test_files.empty?
|
104
|
+
|
105
|
+
if ENV['COV'] || ENV['CI']
|
106
|
+
require 'simplecov'
|
107
|
+
if ENV['CI']
|
108
|
+
begin
|
109
|
+
require 'coveralls'
|
110
|
+
SimpleCov.formatter = Coveralls::SimpleCov::Formatter
|
111
|
+
rescue LoadError => e
|
112
|
+
puts "Cannot load coveralls, skip: #{e}"
|
113
|
+
end
|
114
|
+
end
|
115
|
+
SimpleCov.start do
|
116
|
+
add_filter('test/')
|
117
|
+
add_filter('test.rb')
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
test_files.each{ |file| require "#{dir}/#{file[0..-4]}" }
|
122
|
+
end
|
123
|
+
|
124
|
+
def clean
|
125
|
+
return if ignored_files.empty?
|
126
|
+
|
127
|
+
require 'fileutils'
|
128
|
+
trash = File.expand_path("~/.Trash/#{spec.name}")
|
129
|
+
puts "Move the following files into: \e[35m#{strip_path(trash)}\e[33m"
|
130
|
+
|
131
|
+
ignored_files.each do |file|
|
132
|
+
from = "#{dir}/#{file}"
|
133
|
+
to = "#{trash}/#{File.dirname(file)}"
|
134
|
+
puts strip_path(from)
|
135
|
+
|
136
|
+
FileUtils.mkdir_p(to)
|
137
|
+
FileUtils.mv(from, to)
|
138
|
+
end
|
139
|
+
|
140
|
+
print "\e[0m"
|
141
|
+
end
|
142
|
+
|
41
143
|
def write
|
42
144
|
File.open(spec_path, 'w'){ |f| f << split_lines(spec.to_ruby) }
|
43
145
|
end
|
@@ -144,20 +246,18 @@ module Gemgem
|
|
144
246
|
end
|
145
247
|
|
146
248
|
def ignored_pattern
|
147
|
-
@ignored_pattern ||=
|
249
|
+
@ignored_pattern ||= if gitignore.empty?
|
250
|
+
/^$/
|
251
|
+
else
|
252
|
+
Regexp.new(expand_patterns(gitignore).join('|'))
|
253
|
+
end
|
148
254
|
end
|
149
255
|
|
150
256
|
def expand_patterns pathes
|
151
257
|
# http://git-scm.com/docs/gitignore
|
152
258
|
pathes.flat_map{ |path|
|
153
|
-
|
154
|
-
|
155
|
-
Regexp.escape(path).gsub(/\\\*/, '[^/]*')
|
156
|
-
when %r{^/}
|
157
|
-
"^#{Regexp.escape(path[1..-1])}"
|
158
|
-
else # we didn't implement negative pattern for now
|
159
|
-
Regexp.escape(path)
|
160
|
-
end
|
259
|
+
# we didn't implement negative pattern for now
|
260
|
+
Regexp.escape(path).sub(%r{^/}, '^').gsub(/\\\*/, '[^/]*')
|
161
261
|
}
|
162
262
|
end
|
163
263
|
|
@@ -175,86 +275,38 @@ namespace :gem do
|
|
175
275
|
|
176
276
|
desc 'Install gem'
|
177
277
|
task :install => [:build] do
|
178
|
-
Gemgem.
|
278
|
+
Gemgem.gem_install
|
179
279
|
end
|
180
280
|
|
181
281
|
desc 'Build gem'
|
182
282
|
task :build => [:spec] do
|
183
|
-
|
184
|
-
require 'rubygems/package'
|
185
|
-
gem = nil
|
186
|
-
Dir.chdir(Gemgem.dir) do
|
187
|
-
gem = Gem::Package.build(Gem::Specification.load(Gemgem.spec_path))
|
188
|
-
FileUtils.mkdir_p(Gemgem.pkg_dir)
|
189
|
-
FileUtils.mv(gem, Gemgem.pkg_dir) # gem is relative path, but might be ok
|
190
|
-
end
|
191
|
-
puts "\e[35mGem built: \e[33m" \
|
192
|
-
"#{Gemgem.strip_path("#{Gemgem.pkg_dir}/#{gem}")}\e[0m"
|
283
|
+
Gemgem.gem_build
|
193
284
|
end
|
194
285
|
|
195
286
|
desc 'Generate gemspec'
|
196
287
|
task :spec do
|
197
|
-
Gemgem.
|
198
|
-
Gemgem.write
|
288
|
+
Gemgem.gem_spec
|
199
289
|
end
|
200
290
|
|
201
291
|
desc 'Release gem'
|
202
292
|
task :release => [:spec, :check, :build] do
|
203
|
-
Gemgem.
|
204
|
-
sh_git('tag', Gemgem.gem_tag)
|
205
|
-
sh_git('push')
|
206
|
-
sh_git('push', '--tags')
|
207
|
-
sh_gem('push', Gemgem.gem_path)
|
208
|
-
end
|
293
|
+
Gemgem.gem_release
|
209
294
|
end
|
210
295
|
|
211
296
|
task :check do
|
212
|
-
|
213
|
-
|
214
|
-
if ENV['VERSION'].nil?
|
215
|
-
puts("\e[35mExpected " \
|
216
|
-
"\e[33mVERSION\e[35m=\e[33m#{ver}\e[0m")
|
217
|
-
exit(1)
|
218
|
-
|
219
|
-
elsif ENV['VERSION'] != ver
|
220
|
-
puts("\e[35mExpected \e[33mVERSION\e[35m=\e[33m#{ver} " \
|
221
|
-
"\e[35mbut got\n " \
|
222
|
-
"\e[33mVERSION\e[35m=\e[33m#{ENV['VERSION']}\e[0m")
|
223
|
-
exit(2)
|
224
|
-
end
|
297
|
+
Gemgem.gem_check
|
225
298
|
end
|
226
299
|
|
227
300
|
end # of gem namespace
|
228
301
|
|
229
|
-
desc 'Run tests
|
302
|
+
desc 'Run tests'
|
230
303
|
task :test do
|
231
|
-
|
232
|
-
|
233
|
-
require 'bacon'
|
234
|
-
Bacon.extend(Bacon::TestUnitOutput)
|
235
|
-
Bacon.summary_on_exit
|
236
|
-
Gemgem.test_files.each{ |file| require "#{Gemgem.dir}/#{file[0..-4]}" }
|
304
|
+
Gemgem.test
|
237
305
|
end
|
238
306
|
|
239
|
-
desc '
|
307
|
+
desc 'Trash ignored files'
|
240
308
|
task :clean => ['gem:spec'] do
|
241
|
-
|
242
|
-
|
243
|
-
require 'fileutils'
|
244
|
-
trash = File.expand_path("~/.Trash/#{Gemgem.spec.name}")
|
245
|
-
puts "Move the following files into:" \
|
246
|
-
" \e[35m#{Gemgem.strip_path(trash)}\e[33m"
|
247
|
-
|
248
|
-
Gemgem.ignored_files.each do |file|
|
249
|
-
from = "#{Gemgem.dir}/#{file}"
|
250
|
-
to = "#{trash}/#{File.dirname(file)}"
|
251
|
-
puts Gemgem.strip_path(from)
|
252
|
-
|
253
|
-
FileUtils.mkdir_p(to)
|
254
|
-
FileUtils.mv(from, to)
|
255
|
-
end
|
256
|
-
|
257
|
-
print "\e[0m"
|
309
|
+
Gemgem.clean
|
258
310
|
end
|
259
311
|
|
260
312
|
task :default do
|
data/test/shared.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
|
2
|
+
require 'socket'
|
3
|
+
|
4
|
+
require 'rack'
|
5
|
+
require 'rack-handlers'
|
6
|
+
|
7
|
+
require 'pork'
|
8
|
+
require 'pork/more/bottomup_backtrace'
|
9
|
+
require 'pork/more/color'
|
10
|
+
|
11
|
+
Pork::API.copy :shared do
|
12
|
+
def get name
|
13
|
+
Rack::Handler.get(name)
|
14
|
+
rescue LoadError
|
15
|
+
end
|
16
|
+
|
17
|
+
Rack::Handler::DEFAULT.each do |name|
|
18
|
+
would "launch #{name}" do
|
19
|
+
rd, wr = IO.pipe
|
20
|
+
child = run(name, &wr.method(:puts))
|
21
|
+
msg = rd.gets
|
22
|
+
rd.close
|
23
|
+
skip if msg == "\n"
|
24
|
+
sleep(0.1) if name == 'puma' # slow puma
|
25
|
+
sock = TCPSocket.new('localhost', 8080)
|
26
|
+
sock.binmode
|
27
|
+
sock.print("GET / HTTP/1.1\r\nHost: localhost\r\n\r\n")
|
28
|
+
sock.readline("\r\n\r\n")
|
29
|
+
expect(sock.read(3)).eq "OK\n"
|
30
|
+
sock.close
|
31
|
+
Process.kill('TERM', child)
|
32
|
+
TCPSocket.new('localhost', 8080).close if name == 'yahns' # wake up!
|
33
|
+
Process.waitpid(child)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/test/test_basic.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
|
2
|
+
require_relative 'shared'
|
3
|
+
|
4
|
+
Pork::API.describe Rack::Handler do
|
5
|
+
def app
|
6
|
+
lambda do |_|
|
7
|
+
[200, {}, ["OK\n"]]
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def run name, &block
|
12
|
+
fork do
|
13
|
+
if server = get(name)
|
14
|
+
trap 'TERM' do
|
15
|
+
server.shutdown
|
16
|
+
end if name == 'webrick' # the way to stop webrick
|
17
|
+
|
18
|
+
server.run(app, :Port => 8080){ block.call(name) }
|
19
|
+
else
|
20
|
+
block.call
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
paste :shared
|
26
|
+
end unless RUBY_ENGINE == 'jruby'
|
27
|
+
|
28
|
+
Pork.execute
|
29
|
+
Pork.stat.report
|
data/test/test_rails.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
|
2
|
+
require_relative 'shared'
|
3
|
+
|
4
|
+
Pork::API.describe 'rails-server' do
|
5
|
+
def run name, &block
|
6
|
+
if get(name)
|
7
|
+
pid = Process.spawn('rails', 's', name, '-p', '8080')
|
8
|
+
sleep(1) # slow rails
|
9
|
+
block.call(name)
|
10
|
+
pid
|
11
|
+
else
|
12
|
+
block.call
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
paste :shared
|
17
|
+
end
|
18
|
+
|
19
|
+
Pork.execute
|
20
|
+
Pork.stat.report
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-handlers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lin Jen-Shin (godfat)
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-04-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -33,9 +33,13 @@ extra_rdoc_files: []
|
|
33
33
|
files:
|
34
34
|
- ".gitignore"
|
35
35
|
- ".gitmodules"
|
36
|
+
- ".travis.yml"
|
36
37
|
- CHANGES.md
|
38
|
+
- Gemfile
|
37
39
|
- README.md
|
38
40
|
- Rakefile
|
41
|
+
- config.ru
|
42
|
+
- config/environment.rb
|
39
43
|
- lib/rack-handlers.rb
|
40
44
|
- lib/rack/handler/rails-server.rb
|
41
45
|
- lib/rack/handler/rainbows.rb
|
@@ -43,8 +47,13 @@ files:
|
|
43
47
|
- lib/rack/handler/yahns.rb
|
44
48
|
- lib/rack/handler/zbatery.rb
|
45
49
|
- rack-handlers.gemspec
|
46
|
-
-
|
50
|
+
- script/config.ru
|
51
|
+
- script/rails
|
52
|
+
- task/README.md
|
47
53
|
- task/gemgem.rb
|
54
|
+
- test/shared.rb
|
55
|
+
- test/test_basic.rb
|
56
|
+
- test/test_rails.rb
|
48
57
|
homepage: https://github.com/godfat/rack-handlers
|
49
58
|
licenses:
|
50
59
|
- Apache License 2.0
|
@@ -65,8 +74,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
65
74
|
version: '0'
|
66
75
|
requirements: []
|
67
76
|
rubyforge_project:
|
68
|
-
rubygems_version: 2.
|
77
|
+
rubygems_version: 2.6.3
|
69
78
|
signing_key:
|
70
79
|
specification_version: 4
|
71
80
|
summary: Unicorn family Rack handlers for you. Mostly for `rails s`.
|
72
|
-
test_files:
|
81
|
+
test_files:
|
82
|
+
- test/test_basic.rb
|
83
|
+
- test/test_rails.rb
|
data/task/.gitignore
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
*.rbc
|