shotgun 0.4 → 0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +2 -16
- data/bin/shotgun +14 -7
- data/lib/shotgun.rb +8 -9
- data/shotgun.gemspec +2 -3
- metadata +4 -4
data/Rakefile
CHANGED
@@ -9,14 +9,8 @@ Rake::TestTask.new(:test) do |t|
|
|
9
9
|
t.ruby_opts = ['-rubygems'] if defined? Gem
|
10
10
|
end
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
require 'rubygems/specification'
|
15
|
-
data = File.read('shotgun.gemspec')
|
16
|
-
spec = nil
|
17
|
-
Thread.new { spec = eval("$SAFE = 3\n#{data}") }.join
|
18
|
-
spec
|
19
|
-
end
|
12
|
+
require 'rubygems'
|
13
|
+
$spec = eval(File.read('shotgun.gemspec'))
|
20
14
|
|
21
15
|
def package(ext='')
|
22
16
|
"pkg/#{$spec.name}-#{$spec.version}" + ext
|
@@ -46,11 +40,3 @@ file package('.tar.gz') => %w[pkg/] + $spec.files do |f|
|
|
46
40
|
HEAD | gzip > #{f.name}
|
47
41
|
SH
|
48
42
|
end
|
49
|
-
|
50
|
-
desc 'Publish gem and tarball to rubyforge'
|
51
|
-
task 'release' => [package('.gem'), package('.tar.gz')] do |t|
|
52
|
-
sh <<-end
|
53
|
-
rubyforge add_release wink #{$spec.name} #{$spec.version} #{package('.gem')} &&
|
54
|
-
rubyforge add_file wink #{$spec.name} #{$spec.version} #{package('.tar.gz')}
|
55
|
-
end
|
56
|
-
end
|
data/bin/shotgun
CHANGED
@@ -1,14 +1,17 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
libdir = "#{File.dirname(File.dirname(__FILE__))}/lib"
|
4
|
-
$LOAD_PATH.unshift libdir unless $LOAD_PATH.include?(libdir)
|
5
|
-
|
6
3
|
require 'optparse'
|
7
4
|
|
8
|
-
|
5
|
+
begin
|
6
|
+
require 'thin'
|
7
|
+
server = 'thin'
|
8
|
+
rescue LoadError
|
9
|
+
server = nil
|
10
|
+
end
|
11
|
+
|
9
12
|
env = ENV['RACK_ENV'] || 'development'
|
10
13
|
browse = false
|
11
|
-
options = {:Port => 9393, :Host => 'localhost', :AccessLog => []}
|
14
|
+
options = {:Port => 9393, :Host => 'localhost', :AccessLog => [], :Path => '/'}
|
12
15
|
|
13
16
|
opts = OptionParser.new("", 24, ' ') { |opts|
|
14
17
|
opts.banner = "Usage: shotgun [ruby options] [rack options] [rackup config]"
|
@@ -60,6 +63,10 @@ opts = OptionParser.new("", 24, ' ') { |opts|
|
|
60
63
|
opts.separator ""
|
61
64
|
opts.separator "Shotgun options:"
|
62
65
|
|
66
|
+
opts.on("-u", "--url URL", "specify url path (default: /)") { |url|
|
67
|
+
options[:Path] = url
|
68
|
+
}
|
69
|
+
|
63
70
|
opts.on("-O", "--browse", "open browser immediately after starting") { |browse|
|
64
71
|
browse = true
|
65
72
|
}
|
@@ -127,10 +134,10 @@ require 'shotgun'
|
|
127
134
|
app = Shotgun.new(config, app_wrapper)
|
128
135
|
|
129
136
|
server.run app, options do |inst|
|
130
|
-
puts "== Shotgun starting #{server.to_s} on
|
137
|
+
puts "== Shotgun starting #{server.to_s} on http://#{options[:Host]}:#{options[:Port]}"
|
131
138
|
|
132
139
|
if browse
|
133
140
|
require 'launchy'
|
134
|
-
Launchy.open("http://#{options[:Host]}:#{options[:Port]}
|
141
|
+
Launchy.open("http://#{options[:Host]}:#{options[:Port]}#{options[:Path]}")
|
135
142
|
end
|
136
143
|
end
|
data/lib/shotgun.rb
CHANGED
@@ -9,6 +9,7 @@ class Shotgun
|
|
9
9
|
def initialize(rackup_file, wrapper=nil)
|
10
10
|
@rackup_file = rackup_file
|
11
11
|
@wrapper = wrapper || lambda { |inner_app| inner_app }
|
12
|
+
enable_copy_on_write
|
12
13
|
end
|
13
14
|
|
14
15
|
def call(env)
|
@@ -19,27 +20,21 @@ class Shotgun
|
|
19
20
|
@env = env
|
20
21
|
@reader, @writer = IO.pipe
|
21
22
|
|
22
|
-
|
23
|
-
# out of COW.
|
24
|
-
GC.disable
|
25
|
-
|
26
|
-
if fork
|
23
|
+
if @child = fork
|
27
24
|
proceed_as_parent
|
28
25
|
else
|
29
26
|
proceed_as_child
|
30
27
|
end
|
31
|
-
|
32
|
-
ensure
|
33
|
-
GC.enable
|
34
28
|
end
|
35
29
|
|
36
30
|
# ==== Stuff that happens in the parent process
|
37
31
|
|
38
32
|
def proceed_as_parent
|
33
|
+
rand # Reseeds
|
39
34
|
@writer.close
|
40
35
|
result = Marshal.load(@reader)
|
41
36
|
@reader.close
|
42
|
-
Process.wait
|
37
|
+
Process.wait(@child)
|
43
38
|
if result.length == 3
|
44
39
|
result
|
45
40
|
else
|
@@ -96,4 +91,8 @@ class Shotgun
|
|
96
91
|
body.each { |part| buf << part }
|
97
92
|
buf
|
98
93
|
end
|
94
|
+
|
95
|
+
def enable_copy_on_write
|
96
|
+
GC.copy_on_write_friendly = true if GC.respond_to?(:copy_on_write_friendly=)
|
97
|
+
end
|
99
98
|
end
|
data/shotgun.gemspec
CHANGED
@@ -3,8 +3,8 @@ Gem::Specification.new do |s|
|
|
3
3
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
4
4
|
|
5
5
|
s.name = 'shotgun'
|
6
|
-
s.version = '0.
|
7
|
-
s.date = '
|
6
|
+
s.version = '0.5'
|
7
|
+
s.date = '2010-01-16'
|
8
8
|
|
9
9
|
s.description = "Because reloading sucks."
|
10
10
|
s.summary = s.description
|
@@ -29,6 +29,5 @@ Gem::Specification.new do |s|
|
|
29
29
|
|
30
30
|
s.homepage = "http://github.com/rtomayko/shotgun/"
|
31
31
|
s.require_paths = %w[lib]
|
32
|
-
s.rubyforge_project = 'wink'
|
33
32
|
s.rubygems_version = '1.1.1'
|
34
33
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shotgun
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: "0.
|
4
|
+
version: "0.5"
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Tomayko
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date:
|
12
|
+
date: 2010-01-16 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -73,8 +73,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
73
73
|
version:
|
74
74
|
requirements: []
|
75
75
|
|
76
|
-
rubyforge_project:
|
77
|
-
rubygems_version: 1.3.
|
76
|
+
rubyforge_project:
|
77
|
+
rubygems_version: 1.3.5
|
78
78
|
signing_key:
|
79
79
|
specification_version: 2
|
80
80
|
summary: Because reloading sucks.
|