rack_direct 0.1.10 → 0.1.11
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/rack_direct/active_resource.rb +5 -7
- data/lib/rack_direct/service.rb +17 -10
- data/lib/rack_direct/version.rb +1 -1
- metadata +3 -3
@@ -31,13 +31,11 @@ module RackDirect
|
|
31
31
|
|
32
32
|
result = DirectResponse.new result["status"], result["headers"], result["body"]
|
33
33
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
puts "***** END BODY"
|
40
|
-
end
|
34
|
+
Service.log site.host, "#{result.code} #{result.message}"
|
35
|
+
result.each_header { |k,v| Service.log site.host, "#{k}: #{v}" }
|
36
|
+
Service.log site.host, "START BODY"
|
37
|
+
Service.log site.host, result.body
|
38
|
+
Service.log site.host, "END BODY"
|
41
39
|
|
42
40
|
handle_response(result)
|
43
41
|
end
|
data/lib/rack_direct/service.rb
CHANGED
@@ -13,6 +13,13 @@ module RackDirect
|
|
13
13
|
attr_accessor :verbose_logging
|
14
14
|
end
|
15
15
|
|
16
|
+
def self.log name, msg
|
17
|
+
if self.verbose_logging
|
18
|
+
msg = msg.gsub(/^/, "#{name}> ")
|
19
|
+
puts msg
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
16
23
|
@@services = {}
|
17
24
|
def self.start path, options = {}
|
18
25
|
|
@@ -20,14 +27,14 @@ module RackDirect
|
|
20
27
|
|
21
28
|
unless @@services[name]
|
22
29
|
|
23
|
-
tmppath = generate_rackup_file options[:env]
|
30
|
+
tmppath = generate_rackup_file name, options[:env]
|
24
31
|
|
25
32
|
# TODO: check path to make sure a Rails app exists there
|
26
|
-
|
33
|
+
self.log name, "starting service via rack_direct..."
|
27
34
|
cmd = "cd #{path} && rake db:test:prepare && rackup --server #{RACK_DIRECT_ALIAS} #{tmppath} 2>&1"
|
28
|
-
|
35
|
+
self.log name, cmd
|
29
36
|
@@services[name] = IO.popen cmd, "w+"
|
30
|
-
|
37
|
+
self.log name, "service started"
|
31
38
|
|
32
39
|
at_exit do
|
33
40
|
RackDirect::Service.stop name
|
@@ -58,10 +65,10 @@ module RackDirect
|
|
58
65
|
elsif in_response
|
59
66
|
response += line
|
60
67
|
else
|
61
|
-
|
68
|
+
self.log name, "#{line.strip}"
|
62
69
|
end
|
63
70
|
end
|
64
|
-
|
71
|
+
# self.log name, "Final response: #{response}"
|
65
72
|
response
|
66
73
|
end
|
67
74
|
|
@@ -69,18 +76,18 @@ module RackDirect
|
|
69
76
|
|
70
77
|
def self.stop name
|
71
78
|
if @@services[name]
|
72
|
-
|
79
|
+
self.log name, "stopping service..."
|
73
80
|
@@services[name].puts "EXIT"
|
74
81
|
@@services[name].puts ""
|
75
82
|
@@services[name] = nil
|
76
83
|
Process.waitall
|
77
|
-
|
84
|
+
self.log name, "service stopped."
|
78
85
|
end
|
79
86
|
end
|
80
87
|
|
81
88
|
private
|
82
89
|
|
83
|
-
def self.generate_rackup_file environment
|
90
|
+
def self.generate_rackup_file name, environment
|
84
91
|
rackup_file_contents = <<-EOF
|
85
92
|
require 'rack_direct/direct_handler'
|
86
93
|
Rack::Handler.register('#{RACK_DIRECT_ALIAS}', 'RackDirect::DirectHandler')
|
@@ -106,7 +113,7 @@ EOF
|
|
106
113
|
tmpfile.write rackup_file_contents
|
107
114
|
tmpfile.close
|
108
115
|
|
109
|
-
|
116
|
+
self.log name, "Created rackup file #{tmppath}"
|
110
117
|
|
111
118
|
tmppath
|
112
119
|
end
|
data/lib/rack_direct/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack_direct
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 13
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 11
|
10
|
+
version: 0.1.11
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Brian Sharon
|