shotgun 0.9 → 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +3 -0
- data/CHANGELOG.md +12 -0
- data/{COPYING → LICENSE} +0 -0
- data/{README → README.md} +39 -10
- data/RELEASING +8 -0
- data/bin/shotgun +27 -21
- data/lib/shotgun/loader.rb +1 -0
- data/man/shotgun.1 +24 -3
- data/man/shotgun.1.ronn +21 -2
- data/shotgun.gemspec +8 -29
- data/test/test_shotgun_loader.rb +15 -0
- data/test/verbose.ru +7 -0
- metadata +50 -60
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: bfb95c3ce272fda90c987c9761c981ba16ab692d
|
4
|
+
data.tar.gz: 47182b008d5fcaf9779411bbab72f35053f1a873
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b509cc0e7c7c956c7da7de176ba589d5937e86d195711cc11516a68351742454b8f1adcfb9c37f4be540462725fd81d45c94fe988d976d93dc13f184fdd00827
|
7
|
+
data.tar.gz: 0fa3d9eb2148671e290272f73b51716ec50e7de56c7648a0676bea2f6e44b279557f048971f185e07aac0cf15a1b6031b406ec6133ad18997a065e48e990996e
|
data/.gitignore
ADDED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
0.9.1 - 2015-03-01
|
2
|
+
==================
|
3
|
+
|
4
|
+
* Fixed a long-standing issue that caused Shotgun not to show any access logs
|
5
|
+
in the terminal (#57).
|
6
|
+
|
7
|
+
* Made `--url` option actually work (Adam Mckaig, #49).
|
8
|
+
|
9
|
+
Previous versions
|
10
|
+
=================
|
11
|
+
|
12
|
+
(See commit list.)
|
data/{COPYING → LICENSE}
RENAMED
File without changes
|
data/{README → README.md}
RENAMED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
# Shotgun
|
2
2
|
|
3
3
|
This is an automatic reloading version of the rackup command that's shipped with
|
4
4
|
Rack. It can be used as an alternative to the complex reloading logic provided
|
@@ -16,31 +16,60 @@ Usage
|
|
16
16
|
|
17
17
|
Installation:
|
18
18
|
|
19
|
-
|
19
|
+
```shell
|
20
|
+
gem install shotgun
|
21
|
+
```
|
20
22
|
|
21
23
|
Starting a server with a rackup file:
|
22
24
|
|
23
|
-
|
24
|
-
|
25
|
+
```shell
|
26
|
+
shotgun config.ru
|
27
|
+
```
|
25
28
|
Using Thin and starting on port 6000 instead of 9393 (default):
|
26
29
|
|
27
|
-
|
28
|
-
|
30
|
+
```shell
|
31
|
+
shotgun --server=thin --port=6000 config.ru
|
32
|
+
```
|
29
33
|
Running Sinatra apps:
|
30
34
|
|
31
|
-
|
35
|
+
|
36
|
+
```shell
|
37
|
+
shotgun hello.rb
|
38
|
+
```
|
32
39
|
|
33
40
|
See 'shotgun --help' for more advanced usage.
|
34
41
|
|
42
|
+
Compatibility
|
43
|
+
---
|
44
|
+
|
45
|
+
Because of the underlying technique used, Shotgun is only compatible with
|
46
|
+
systems that support `fork(2)` (probably just MRI on POSIX systems).
|
47
|
+
|
48
|
+
Caveats
|
49
|
+
---
|
50
|
+
|
51
|
+
* For performance reasons, Shotgun automatically includes middleware to serve
|
52
|
+
static files (similar to `Rack::Static`). If you rely on Rack serving static
|
53
|
+
assets, then do include `Rack::Static` yourself.
|
54
|
+
|
55
|
+
* If you use Sinatra, you may need to [set the session secret manually][sinatra-caveat].
|
56
|
+
|
57
|
+
* Similar to a Rackup file (`config.ru`), you can't use `require_relative` in
|
58
|
+
your preload files (`shotgun.rb`).
|
59
|
+
|
35
60
|
Links
|
36
61
|
-----
|
37
62
|
|
38
|
-
Shotgun
|
39
|
-
|
40
|
-
|
63
|
+
[Shotgun](http://github.com/rtomayko/shotgun)
|
64
|
+
|
65
|
+
[Rack](http://rack.rubyforge.org/)
|
66
|
+
|
67
|
+
[Sinatra](http://www.sinatrarb.com/)
|
41
68
|
|
42
69
|
The reloading system in Ian Bicking's webware framework served as inspiration
|
43
70
|
for the approach taken in Shotgun. Ian lays down the pros and cons of this
|
44
71
|
approach in the following article:
|
45
72
|
|
46
73
|
http://ianbicking.org/docs/Webware_reload.html
|
74
|
+
|
75
|
+
[sinatra-caveat]: https://groups.google.com/forum/#!topic/sinatrarb/pUFSoyQXyQs
|
data/RELEASING
ADDED
data/bin/shotgun
CHANGED
@@ -3,10 +3,13 @@
|
|
3
3
|
require 'optparse'
|
4
4
|
|
5
5
|
env = ENV['RACK_ENV'] || 'development'
|
6
|
+
host = ENV['HOST'] || '127.0.0.1'
|
7
|
+
port = ENV['PORT'] || 9393
|
8
|
+
mount_path = "/"
|
6
9
|
browse = false
|
7
10
|
server = nil
|
8
11
|
public_dir = 'public' if File.directory?('public')
|
9
|
-
options = {:Port =>
|
12
|
+
options = {:Port => port, :Host => host, :AccessLog => []}
|
10
13
|
|
11
14
|
opts = OptionParser.new("", 24, ' ') { |opts|
|
12
15
|
opts.banner = "Usage: shotgun [ruby options] [rack options] [rackup config]"
|
@@ -58,12 +61,12 @@ opts = OptionParser.new("", 24, ' ') { |opts|
|
|
58
61
|
opts.separator ""
|
59
62
|
opts.separator "Shotgun options:"
|
60
63
|
|
61
|
-
opts.on("-O", "--browse", "open browser immediately after starting") {
|
64
|
+
opts.on("-O", "--browse", "open browser immediately after starting") {
|
62
65
|
browse = true
|
63
66
|
}
|
64
67
|
|
65
|
-
opts.on("-u", "--url URL", "specify url path (default:
|
66
|
-
|
68
|
+
opts.on("-u", "--url URL", "specify url path (default: #{mount_path})") { |url|
|
69
|
+
mount_path = url
|
67
70
|
}
|
68
71
|
|
69
72
|
opts.on("-P", "--public PATH", "serve static files under PATH") { |path|
|
@@ -116,22 +119,25 @@ server = Rack::Handler.get(server) || Rack::Handler.default
|
|
116
119
|
|
117
120
|
app =
|
118
121
|
Rack::Builder.new do
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
122
|
+
map(mount_path) do
|
123
|
+
|
124
|
+
# these middleware run in the master process.
|
125
|
+
use Shotgun::Static, public_dir if public_dir
|
126
|
+
use Shotgun::SkipFavicon
|
127
|
+
|
128
|
+
# loader forks the child and runs the embedded config followed by the
|
129
|
+
# application config.
|
130
|
+
run Shotgun::Loader.new(config) {
|
131
|
+
case env
|
132
|
+
when 'development'
|
133
|
+
use Rack::CommonLogger, STDERR unless server.name =~ /CGI/
|
134
|
+
use Rack::ShowExceptions
|
135
|
+
use Rack::Lint
|
136
|
+
when 'deployment', 'production'
|
137
|
+
use Rack::CommonLogger, STDERR unless server.name =~ /CGI/
|
138
|
+
end
|
139
|
+
}
|
140
|
+
end
|
135
141
|
end
|
136
142
|
|
137
143
|
Shotgun.enable_copy_on_write
|
@@ -151,7 +157,7 @@ end
|
|
151
157
|
# load shotgun.rb in current working directory if it exists
|
152
158
|
Shotgun.preload
|
153
159
|
|
154
|
-
base_url = "http://#{options[:Host]}:#{options[:Port]}#{
|
160
|
+
base_url = "http://#{options[:Host]}:#{options[:Port]}#{mount_path}"
|
155
161
|
puts "== Shotgun/#{server.to_s.sub(/Rack::Handler::/, '')} on #{base_url}"
|
156
162
|
server.run app, options do |inst|
|
157
163
|
if browse
|
data/lib/shotgun/loader.rb
CHANGED
@@ -86,6 +86,7 @@ module Shotgun
|
|
86
86
|
status, headers, body = assemble_app.call(@env)
|
87
87
|
Marshal.dump([:ok, status, headers.to_hash], @writer)
|
88
88
|
spec_body(body).each { |chunk| @writer.write(chunk) }
|
89
|
+
body.close if body.respond_to?(:close)
|
89
90
|
rescue Object => boom
|
90
91
|
Marshal.dump([
|
91
92
|
:error,
|
data/man/shotgun.1
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
.\" generated with Ronn/v0.7.3
|
2
2
|
.\" http://github.com/rtomayko/ronn/tree/0.7.3
|
3
3
|
.
|
4
|
-
.TH "SHOTGUN" "1" "
|
4
|
+
.TH "SHOTGUN" "1" "March 2015" "Shotgun 0.9.1" ""
|
5
5
|
.
|
6
6
|
.SH "NAME"
|
7
7
|
\fBshotgun\fR \- reloading rack development server
|
@@ -35,11 +35,11 @@ The Rack server handler implementation used to serve requests\. Supported values
|
|
35
35
|
.
|
36
36
|
.TP
|
37
37
|
\fB\-o\fR, \fB\-\-host\fR=\fIaddr\fR
|
38
|
-
The hostname or address of the interface the HTTP server should bind to\. Default: \fB127\.0\.0\.1\fR\.
|
38
|
+
The hostname or address of the interface the HTTP server should bind to\. Overrides the \fBHOST\fR environment variable\. Default: \fB127\.0\.0\.1\fR\.
|
39
39
|
.
|
40
40
|
.TP
|
41
41
|
\fB\-p\fR, \fB\-\-port\fR=\fIport\fR
|
42
|
-
The port the HTTP server should bind to\. Default: \fB9393\fR\.
|
42
|
+
The port the HTTP server should bind to\. Overrides the \fBPORT\fR environment variable\. Default: \fB9393\fR\.
|
43
43
|
.
|
44
44
|
.TP
|
45
45
|
\fB\-O\fR, \fB\-\-browse\fR
|
@@ -79,6 +79,17 @@ Show usage message and exit\.
|
|
79
79
|
\fB\-\-version\fR
|
80
80
|
Show the Rack version and exit\.
|
81
81
|
.
|
82
|
+
.SH "ENVIRONMENT"
|
83
|
+
The following environment variables affect the configuration of \fBshotgun\fR:
|
84
|
+
.
|
85
|
+
.TP
|
86
|
+
\fBHOST\fR
|
87
|
+
The hostname or address of the interface the HTTP server should bind to\. See the \fB\-h\fR option\.
|
88
|
+
.
|
89
|
+
.TP
|
90
|
+
\fBPORT\fR
|
91
|
+
The port the HTTP server should bind to\. See the \fB\-p\fR option\.
|
92
|
+
.
|
82
93
|
.SH "PRELOADING"
|
83
94
|
It\'s possible to load support libraries and portions of the application in the shotgun master process to reduce the amount of work that needs to be done for each request in worker processes\. There\'s two ways of accomplishing this: either by specifying one or more \fB\-\-require\fR (\fB\-r\fR) arguments or through the use of a \fBshotgun\.rb\fR file\.
|
84
95
|
.
|
@@ -145,6 +156,16 @@ Fork and report issues at github\.com:
|
|
145
156
|
.
|
146
157
|
.SH "VERSION HISTORY"
|
147
158
|
.
|
159
|
+
.SS "Version 0\.9\.1 (2015 March 1)"
|
160
|
+
.
|
161
|
+
.IP "\(bu" 4
|
162
|
+
Fix a long\-standing issue that caused Shotgun not to show any access logs in the terminal (#57)\.
|
163
|
+
.
|
164
|
+
.IP "\(bu" 4
|
165
|
+
Make \fB\-\-url\fR option actually work\.
|
166
|
+
.
|
167
|
+
.IP "" 0
|
168
|
+
.
|
148
169
|
.SS "Version 0\.9 (2011 February 24)"
|
149
170
|
.
|
150
171
|
.IP "\(bu" 4
|
data/man/shotgun.1.ronn
CHANGED
@@ -46,10 +46,11 @@ control server behavior:
|
|
46
46
|
|
47
47
|
* `-o`, `--host`=<addr>:
|
48
48
|
The hostname or address of the interface the HTTP server should bind to.
|
49
|
-
Default: `127.0.0.1`.
|
49
|
+
Overrides the `HOST` environment variable. Default: `127.0.0.1`.
|
50
50
|
|
51
51
|
* `-p`, `--port`=<port>:
|
52
|
-
The port the HTTP server should bind to.
|
52
|
+
The port the HTTP server should bind to. Overrides the `PORT` environment
|
53
|
+
variable. Default: `9393`.
|
53
54
|
|
54
55
|
* `-O`, `--browse`:
|
55
56
|
Open browser at http://<host>:<port>/ immediately after the server
|
@@ -86,6 +87,17 @@ Miscellaneous:
|
|
86
87
|
* `--version`:
|
87
88
|
Show the Rack version and exit.
|
88
89
|
|
90
|
+
## ENVIRONMENT
|
91
|
+
|
92
|
+
The following environment variables affect the configuration of `shotgun`:
|
93
|
+
|
94
|
+
* `HOST`:
|
95
|
+
The hostname or address of the interface the HTTP server should bind to. See
|
96
|
+
the `-h` option.
|
97
|
+
|
98
|
+
* `PORT`:
|
99
|
+
The port the HTTP server should bind to. See the `-p` option.
|
100
|
+
|
89
101
|
## PRELOADING
|
90
102
|
|
91
103
|
It's possible to load support libraries and portions of the application in the
|
@@ -148,6 +160,13 @@ Fork and report issues at github.com:
|
|
148
160
|
|
149
161
|
## VERSION HISTORY
|
150
162
|
|
163
|
+
### Version 0.9.1 (2015 March 1)
|
164
|
+
|
165
|
+
* Fix a long-standing issue that caused Shotgun not to show any access logs
|
166
|
+
in the terminal (#57).
|
167
|
+
|
168
|
+
* Make `--url` option actually work.
|
169
|
+
|
151
170
|
### Version 0.9 (2011 February 24)
|
152
171
|
|
153
172
|
* <http://github.com/rtomayko/shotgun/compare/0.8...0.9>
|
data/shotgun.gemspec
CHANGED
@@ -1,41 +1,20 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'shotgun'
|
3
|
-
s.version = '0.9'
|
4
|
-
s.date = '2011-02-24'
|
3
|
+
s.version = '0.9.1'
|
5
4
|
|
6
|
-
s.description = "
|
5
|
+
s.description = "Reloading Rack development server"
|
7
6
|
s.summary = s.description
|
8
7
|
|
8
|
+
s.license = "MIT"
|
9
|
+
|
9
10
|
s.authors = ["Ryan Tomayko"]
|
10
11
|
s.email = "rtomayko@gmail.com"
|
11
12
|
|
12
|
-
s.files
|
13
|
-
|
14
|
-
|
15
|
-
Rakefile
|
16
|
-
bin/shotgun
|
17
|
-
lib/shotgun.rb
|
18
|
-
lib/shotgun/favicon.rb
|
19
|
-
lib/shotgun/loader.rb
|
20
|
-
lib/shotgun/static.rb
|
21
|
-
man/index.txt
|
22
|
-
man/shotgun.1
|
23
|
-
man/shotgun.1.ronn
|
24
|
-
shotgun.gemspec
|
25
|
-
test/big.ru
|
26
|
-
test/boom.ru
|
27
|
-
test/slow.ru
|
28
|
-
test/test-sinatra.ru
|
29
|
-
test/test.ru
|
30
|
-
test/test_shotgun_loader.rb
|
31
|
-
test/test_shotgun_static.rb
|
32
|
-
]
|
33
|
-
s.executables = ['shotgun']
|
34
|
-
s.test_files = s.files.select { |f| f =~ /test_shotgun.*rb/ }
|
13
|
+
s.files = `git ls-files`.split("\n")
|
14
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
15
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
35
16
|
|
36
|
-
s.extra_rdoc_files = %w[README]
|
37
17
|
s.add_dependency 'rack', '>= 1.0'
|
38
18
|
|
39
|
-
s.homepage = "
|
40
|
-
s.require_paths = %w[lib]
|
19
|
+
s.homepage = "https://github.com/rtomayko/shotgun"
|
41
20
|
end
|
data/test/test_shotgun_loader.rb
CHANGED
@@ -32,4 +32,19 @@ class ShotgunLoaderTest < Test::Unit::TestCase
|
|
32
32
|
assert res.body =~ %r|<pre>(?:.{1023}\n){1024}</pre>|,
|
33
33
|
"body of size #{res.body.size} does not match expected output"
|
34
34
|
end
|
35
|
+
|
36
|
+
def test_logging
|
37
|
+
file = rackup_file('verbose.ru')
|
38
|
+
|
39
|
+
$logger = File.open('test/verbose.log', 'w')
|
40
|
+
$logger.sync = true
|
41
|
+
|
42
|
+
shotgun = Shotgun::Loader.new(file)
|
43
|
+
request = Rack::MockRequest.new(shotgun)
|
44
|
+
request.get('/', 'REMOTE_ADDR' => 'foo.local')
|
45
|
+
|
46
|
+
$logger.close
|
47
|
+
|
48
|
+
assert_match /^foo.local/, File.read('test/verbose.log')
|
49
|
+
end
|
35
50
|
end
|
data/test/verbose.ru
ADDED
metadata
CHANGED
@@ -1,48 +1,41 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: shotgun
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease: false
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 9
|
9
|
-
version: "0.9"
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.9.1
|
10
5
|
platform: ruby
|
11
|
-
authors:
|
6
|
+
authors:
|
12
7
|
- Ryan Tomayko
|
13
8
|
autorequire:
|
14
9
|
bindir: bin
|
15
10
|
cert_chain: []
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
dependencies:
|
20
|
-
- !ruby/object:Gem::Dependency
|
11
|
+
date: 2015-03-01 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
21
14
|
name: rack
|
22
|
-
|
23
|
-
|
24
|
-
none: false
|
25
|
-
requirements:
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
26
17
|
- - ">="
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
|
29
|
-
segments:
|
30
|
-
- 1
|
31
|
-
- 0
|
32
|
-
version: "1.0"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.0'
|
33
20
|
type: :runtime
|
34
|
-
|
35
|
-
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.0'
|
27
|
+
description: Reloading Rack development server
|
36
28
|
email: rtomayko@gmail.com
|
37
|
-
executables:
|
29
|
+
executables:
|
38
30
|
- shotgun
|
39
31
|
extensions: []
|
40
|
-
|
41
|
-
|
42
|
-
-
|
43
|
-
|
44
|
-
-
|
45
|
-
- README
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- ".gitignore"
|
35
|
+
- CHANGELOG.md
|
36
|
+
- LICENSE
|
37
|
+
- README.md
|
38
|
+
- RELEASING
|
46
39
|
- Rakefile
|
47
40
|
- bin/shotgun
|
48
41
|
- lib/shotgun.rb
|
@@ -60,40 +53,37 @@ files:
|
|
60
53
|
- test/test.ru
|
61
54
|
- test/test_shotgun_loader.rb
|
62
55
|
- test/test_shotgun_static.rb
|
63
|
-
|
64
|
-
homepage:
|
65
|
-
licenses:
|
66
|
-
|
56
|
+
- test/verbose.ru
|
57
|
+
homepage: https://github.com/rtomayko/shotgun
|
58
|
+
licenses:
|
59
|
+
- MIT
|
60
|
+
metadata: {}
|
67
61
|
post_install_message:
|
68
62
|
rdoc_options: []
|
69
|
-
|
70
|
-
require_paths:
|
63
|
+
require_paths:
|
71
64
|
- lib
|
72
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
73
|
-
|
74
|
-
requirements:
|
65
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
75
67
|
- - ">="
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
version: "0"
|
81
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
82
|
-
none: false
|
83
|
-
requirements:
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
84
72
|
- - ">="
|
85
|
-
- !ruby/object:Gem::Version
|
86
|
-
|
87
|
-
segments:
|
88
|
-
- 0
|
89
|
-
version: "0"
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
90
75
|
requirements: []
|
91
|
-
|
92
76
|
rubyforge_project:
|
93
|
-
rubygems_version:
|
77
|
+
rubygems_version: 2.4.5
|
94
78
|
signing_key:
|
95
|
-
specification_version:
|
96
|
-
summary:
|
97
|
-
test_files:
|
79
|
+
specification_version: 4
|
80
|
+
summary: Reloading Rack development server
|
81
|
+
test_files:
|
82
|
+
- test/big.ru
|
83
|
+
- test/boom.ru
|
84
|
+
- test/slow.ru
|
85
|
+
- test/test-sinatra.ru
|
86
|
+
- test/test.ru
|
98
87
|
- test/test_shotgun_loader.rb
|
99
88
|
- test/test_shotgun_static.rb
|
89
|
+
- test/verbose.ru
|