shotgun 0.3 → 0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/shotgun.rb +17 -3
  2. data/shotgun.gemspec +1 -1
  3. metadata +5 -3
data/lib/shotgun.rb CHANGED
@@ -1,7 +1,9 @@
1
1
  require 'rack'
2
+ require 'rack/utils'
2
3
  require 'thread'
3
4
 
4
5
  class Shotgun
6
+ include Rack::Utils
5
7
  attr_reader :rackup_file
6
8
 
7
9
  def initialize(rackup_file, wrapper=nil)
@@ -35,10 +37,20 @@ class Shotgun
35
37
 
36
38
  def proceed_as_parent
37
39
  @writer.close
38
- status, headers, body = Marshal.load(@reader)
40
+ result = Marshal.load(@reader)
39
41
  @reader.close
40
42
  Process.wait
41
- [status, headers, body]
43
+ if result.length == 3
44
+ result
45
+ else
46
+ [500, {'Content-Type'=>'text/html;charset=utf-8'}, [format_error(result)]]
47
+ end
48
+ end
49
+
50
+ def format_error(result)
51
+ message, backtrace = result
52
+ "<h1>FAIL</h1><h3>#{escape_html(message)}</h3>" +
53
+ "<pre>#{escape_html(backtrace.join("\n"))}</pre>"
42
54
  end
43
55
 
44
56
  # ==== Stuff that happens in the forked child process.
@@ -49,7 +61,9 @@ class Shotgun
49
61
  status, headers, body = app.call(@env)
50
62
  Marshal.dump([status, headers.to_hash, slurp(body)], @writer)
51
63
  @writer.close
52
- ensure
64
+ rescue Object => boom
65
+ Marshal.dump(["#{boom.class.name}: #{boom.to_s}", boom.backtrace], @writer)
66
+ ensure
53
67
  exit! 0
54
68
  end
55
69
 
data/shotgun.gemspec CHANGED
@@ -3,7 +3,7 @@ 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.3'
6
+ s.version = '0.4'
7
7
  s.date = '2009-03-22'
8
8
 
9
9
  s.description = "Because reloading sucks."
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.3"
4
+ version: "0.4"
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Tomayko
@@ -50,8 +50,10 @@ files:
50
50
  - shotgun.gemspec
51
51
  - lib/shotgun.rb
52
52
  - bin/shotgun
53
- has_rdoc: false
53
+ has_rdoc: true
54
54
  homepage: http://github.com/rtomayko/shotgun/
55
+ licenses: []
56
+
55
57
  post_install_message:
56
58
  rdoc_options: []
57
59
 
@@ -72,7 +74,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
72
74
  requirements: []
73
75
 
74
76
  rubyforge_project: wink
75
- rubygems_version: 1.3.1
77
+ rubygems_version: 1.3.4
76
78
  signing_key:
77
79
  specification_version: 2
78
80
  summary: Because reloading sucks.