jubilee 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. data/.rbenv-version +1 -0
  2. data/Gemfile +16 -0
  3. data/Gemfile.lock +54 -0
  4. data/Guardfile +24 -0
  5. data/README.md +61 -0
  6. data/Rakefile +94 -0
  7. data/VERSION +1 -0
  8. data/bin/jubilee +6 -0
  9. data/bin/jubilee_d +10 -0
  10. data/examples/jubilee/keystore.jks +0 -0
  11. data/examples/jubilee/server-keystore.jks +0 -0
  12. data/examples/ssl/ServerTest.java +19 -0
  13. data/examples/ssl/webroot/index.html +10 -0
  14. data/jars/netty-3.6.0.Beta1.jar +0 -0
  15. data/jars/vertx-core-1.3.0.final.jar +0 -0
  16. data/java/.idea/ant.xml +7 -0
  17. data/java/.idea/libraries/jruby.xml +9 -0
  18. data/java/.idea/libraries/netty_3_6_0_Beta1.xml +9 -0
  19. data/java/.idea/libraries/vertx_core_1_3_0_final.xml +9 -0
  20. data/java/src/jubilee/JubileeService.java +21 -0
  21. data/java/src/org/jruby/jubilee/Const.java +148 -0
  22. data/java/src/org/jruby/jubilee/RackApplication.java +78 -0
  23. data/java/src/org/jruby/jubilee/RackEnvironment.java +13 -0
  24. data/java/src/org/jruby/jubilee/RackErrors.java +44 -0
  25. data/java/src/org/jruby/jubilee/RackInput.java +62 -0
  26. data/java/src/org/jruby/jubilee/RackResponse.java +16 -0
  27. data/java/src/org/jruby/jubilee/Server.java +104 -0
  28. data/java/src/org/jruby/jubilee/deploy/Starter.java +26 -0
  29. data/java/src/org/jruby/jubilee/impl/DefaultRackEnvironment.java +98 -0
  30. data/java/src/org/jruby/jubilee/impl/NullIO.java +111 -0
  31. data/java/src/org/jruby/jubilee/impl/RubyIORackErrors.java +68 -0
  32. data/java/src/org/jruby/jubilee/impl/RubyIORackInput.java +164 -0
  33. data/lib/jubilee.rb +11 -0
  34. data/lib/jubilee/application.rb +13 -0
  35. data/lib/jubilee/cli.rb +74 -0
  36. data/lib/jubilee/configuration.rb +52 -0
  37. data/lib/jubilee/const.rb +39 -0
  38. data/lib/jubilee/jubilee.jar +0 -0
  39. data/lib/jubilee/response.rb +64 -0
  40. data/lib/jubilee/server.rb +16 -0
  41. data/lib/rack/handler/jubilee.rb +43 -0
  42. data/test/.rbenv-version +1 -0
  43. data/test/config/app.rb +5 -0
  44. data/test/jubilee/test_cli.rb +11 -0
  45. data/test/jubilee/test_config.rb +14 -0
  46. data/test/jubilee/test_persistent.rb +238 -0
  47. data/test/jubilee/test_rack_server.rb +116 -0
  48. data/test/jubilee/test_server.rb +68 -0
  49. data/test/sinatra_app/app.rb +31 -0
  50. data/test/sinatra_app/config.ru +6 -0
  51. data/test/sinatra_app/public/test.html +10 -0
  52. data/test/sinatra_app/unicorn.conf.rb +29 -0
  53. data/test/test_helper.rb +21 -0
  54. metadata +160 -0
@@ -0,0 +1,68 @@
1
+ require 'test_helper'
2
+ require 'net/http'
3
+
4
+ class TestJubileeServer < MiniTest::Unit::TestCase
5
+ def setup
6
+ @host, @port = "localhost", 3215
7
+ end
8
+
9
+ def test_server_lambda
10
+ app = lambda {|env| [200, {"Content-Type" => "text/plain"}, ["http"]] }
11
+ server = Jubilee::Server.new(app)
12
+ server.start
13
+
14
+ http, body = Net::HTTP.new(@host, @port), nil
15
+ http.start do
16
+ req = Net::HTTP::Get.new "/", {}
17
+ http.request(req) do |resp|
18
+ body = resp.body
19
+ end
20
+ end
21
+ server.stop
22
+ assert_equal "http", body
23
+ end
24
+
25
+ def test_server_embeded
26
+ config = Jubilee::Configuration.new(rackup: File.join(File.dirname(__FILE__), "../config/app.rb"))
27
+ config.load
28
+ server = Jubilee::Server.new(config.app)
29
+ server.start
30
+ http, body = Net::HTTP.new(@host, @port), nil
31
+ http.start do
32
+ req = Net::HTTP::Get.new "/", {}
33
+ http.request(req) do |resp|
34
+ body = resp.body
35
+ end
36
+ end
37
+ server.stop
38
+ assert_equal "embeded app", body
39
+ end
40
+
41
+ def test_large_post_body
42
+ skip
43
+ end
44
+
45
+
46
+ def test_url_scheme_for_https
47
+ app = lambda { |env| [200, {}, [env['rack.url_scheme']]] }
48
+ server = Jubilee::Server.new(app, {port:@port, ssl:true,
49
+ keystore: File.join(File.dirname(__FILE__), "../../examples/jubilee/server-keystore.jks"),
50
+ keystore_password: "wibble"})
51
+ server.start
52
+ http = Net::HTTP.new @host, @port
53
+ http.use_ssl = true
54
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
55
+
56
+ body = nil
57
+ http.start do
58
+ req = Net::HTTP::Get.new "/", {}
59
+
60
+ http.request(req) do |rep|
61
+ body = rep.body
62
+ end
63
+ end
64
+
65
+ server.stop
66
+ assert_equal "https", body
67
+ end
68
+ end
@@ -0,0 +1,31 @@
1
+ #$:.unshift("/home/isaiah/codes/ruby/rack/lib")
2
+ require 'sinatra'
3
+
4
+ class Vertx < Sinatra::Base
5
+ get '/' do
6
+ "<h1>Hello Sinatra!</h1>"
7
+ end
8
+
9
+ post "/home/test" do
10
+ #require 'pp'
11
+ #pp env['rack.input'].gets
12
+ #require 'rack/multipart'
13
+ #puts "=========="
14
+ ##pp Rack::Multipart.parse_multipart(env)
15
+ #puts "=========="
16
+ ##pp env
17
+ #pp request.params
18
+ #puts "=========="
19
+ a = ""
20
+ params.each{|k,v| a << "#{k}:#{v}\n"}
21
+ a
22
+ end
23
+
24
+ get '/app' do
25
+ <<EOF
26
+ <h1>Powered by Jubilee</h1>
27
+ <a href="http://www.github.com/isaiah/jubilee">Homepage</a>
28
+ <p>Date: #{Time.now.strftime("%m %d, %Y")}</p>
29
+ EOF
30
+ end
31
+ end
@@ -0,0 +1,6 @@
1
+ require './app'
2
+ #$:.unshift("/home/isaiah/codes/ruby/rack/lib")
3
+ #require 'pp'
4
+ #require 'rack/multipart'
5
+ #run lambda { |env| pp env; puts "=="; pp env['rack.input'].gets; puts "=="; params = Rack::Multipart.parse_multipart(env); pp params; [200, {"Content-Type" => "text/plain", "Content-Length" => "44"}, params.map{|k,v| k + ":" + v}] }
6
+ run Vertx
@@ -0,0 +1,10 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <title>Test</title>
6
+ </head>
7
+ <body>
8
+ This is a test page.
9
+ </body>
10
+ </html>
@@ -0,0 +1,29 @@
1
+ # Use at least one worker per core if you're on a dedicated server,
2
+ # more will usually help for _short_ waits on databases/caches.
3
+ worker_processes 10
4
+
5
+ # Since Unicorn is never exposed to outside clients, it does not need to
6
+ # run on the standard HTTP port (80), there is no reason to start Unicorn
7
+ # as root unless it's from system init scripts.
8
+ # If running the master process as root and the workers as an unprivileged
9
+ # user, do this to switch euid/egid in the workers (also chowns logs):
10
+ # user "unprivileged_user", "unprivileged_group"
11
+
12
+ # Help ensure your application will always spawn in the symlinked
13
+ # "current" directory that Capistrano sets up.
14
+
15
+ # listen on both a Unix domain socket and a TCP port,
16
+ # we use a shorter backlog for quicker failover when busy
17
+ listen 8080, :tcp_nopush => true
18
+
19
+ # nuke workers after 30 seconds instead of 60 seconds (the default)
20
+ timeout 30
21
+
22
+ # feel free to point this anywhere accessible on the filesystem
23
+ pid "/tmp/unicorn.pid"
24
+
25
+ # By default, the Unicorn logger will write to stderr.
26
+ # Additionally, ome applications/frameworks log to stderr or stdout,
27
+ # so prevent them from going to /dev/null when daemonized here:
28
+ #stderr_path "log/unicorn.stderr.log"
29
+ #stdout_path "log/unicorn.stdout.log"
@@ -0,0 +1,21 @@
1
+ $:.unshift(File.join(File.dirname(__FILE__), "../lib"))
2
+ require 'minitest/autorun'
3
+ require 'minitest/unit'
4
+ require 'jubilee'
5
+ require 'net/http'
6
+ require 'net/http/post/multipart'
7
+ def hit(uris)
8
+ uris.map do |u|
9
+ res = nil
10
+
11
+ if u.kind_of? String
12
+ res = Net::HTTP.get(URI.parse(u))
13
+ else
14
+ url = URI.parse(u[0])
15
+ res = Net::HTTP.new(url.host, url.port).start {|h| h.request(u[1]) }
16
+ end
17
+
18
+ assert res != nil, "Didn't get a response: #{u}"
19
+ res
20
+ end
21
+ end
metadata ADDED
@@ -0,0 +1,160 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jubilee
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.1.2
6
+ platform: ruby
7
+ authors:
8
+ - Isaiah Peng
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-12-10 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rack
16
+ version_requirements: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ! '>='
19
+ - !ruby/object:Gem::Version
20
+ version: !binary |-
21
+ MA==
22
+ none: false
23
+ requirement: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ! '>='
26
+ - !ruby/object:Gem::Version
27
+ version: !binary |-
28
+ MA==
29
+ none: false
30
+ prerelease: false
31
+ type: :runtime
32
+ - !ruby/object:Gem::Dependency
33
+ name: spoon
34
+ version_requirements: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ! '>='
37
+ - !ruby/object:Gem::Version
38
+ version: !binary |-
39
+ MA==
40
+ none: false
41
+ requirement: !ruby/object:Gem::Requirement
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: !binary |-
46
+ MA==
47
+ none: false
48
+ prerelease: false
49
+ type: :runtime
50
+ - !ruby/object:Gem::Dependency
51
+ name: jeweler
52
+ version_requirements: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ! '>='
55
+ - !ruby/object:Gem::Version
56
+ version: !binary |-
57
+ MA==
58
+ none: false
59
+ requirement: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ! '>='
62
+ - !ruby/object:Gem::Version
63
+ version: !binary |-
64
+ MA==
65
+ none: false
66
+ prerelease: false
67
+ type: :development
68
+ description: Web Server that rocks!
69
+ email: issaria@gmail.com
70
+ executables:
71
+ - jubilee
72
+ - jubilee_d
73
+ extensions: []
74
+ extra_rdoc_files:
75
+ - README.md
76
+ files:
77
+ - .rbenv-version
78
+ - Gemfile
79
+ - Gemfile.lock
80
+ - Guardfile
81
+ - README.md
82
+ - Rakefile
83
+ - VERSION
84
+ - bin/jubilee
85
+ - bin/jubilee_d
86
+ - examples/jubilee/keystore.jks
87
+ - examples/jubilee/server-keystore.jks
88
+ - examples/ssl/ServerTest.java
89
+ - examples/ssl/webroot/index.html
90
+ - jars/netty-3.6.0.Beta1.jar
91
+ - jars/vertx-core-1.3.0.final.jar
92
+ - java/.idea/ant.xml
93
+ - java/.idea/libraries/jruby.xml
94
+ - java/.idea/libraries/netty_3_6_0_Beta1.xml
95
+ - java/.idea/libraries/vertx_core_1_3_0_final.xml
96
+ - java/src/jubilee/JubileeService.java
97
+ - java/src/org/jruby/jubilee/Const.java
98
+ - java/src/org/jruby/jubilee/RackApplication.java
99
+ - java/src/org/jruby/jubilee/RackEnvironment.java
100
+ - java/src/org/jruby/jubilee/RackErrors.java
101
+ - java/src/org/jruby/jubilee/RackInput.java
102
+ - java/src/org/jruby/jubilee/RackResponse.java
103
+ - java/src/org/jruby/jubilee/Server.java
104
+ - java/src/org/jruby/jubilee/deploy/Starter.java
105
+ - java/src/org/jruby/jubilee/impl/DefaultRackEnvironment.java
106
+ - java/src/org/jruby/jubilee/impl/NullIO.java
107
+ - java/src/org/jruby/jubilee/impl/RubyIORackErrors.java
108
+ - java/src/org/jruby/jubilee/impl/RubyIORackInput.java
109
+ - lib/jubilee.rb
110
+ - lib/jubilee/application.rb
111
+ - lib/jubilee/cli.rb
112
+ - lib/jubilee/configuration.rb
113
+ - lib/jubilee/const.rb
114
+ - lib/jubilee/jubilee.jar
115
+ - lib/jubilee/response.rb
116
+ - lib/jubilee/server.rb
117
+ - lib/rack/handler/jubilee.rb
118
+ - test/.rbenv-version
119
+ - test/config/app.rb
120
+ - test/jubilee/test_cli.rb
121
+ - test/jubilee/test_config.rb
122
+ - test/jubilee/test_persistent.rb
123
+ - test/jubilee/test_rack_server.rb
124
+ - test/jubilee/test_server.rb
125
+ - test/sinatra_app/app.rb
126
+ - test/sinatra_app/config.ru
127
+ - test/sinatra_app/public/test.html
128
+ - test/sinatra_app/unicorn.conf.rb
129
+ - test/test_helper.rb
130
+ homepage: http://github.com/isaiah/jubilee
131
+ licenses:
132
+ - MIT
133
+ post_install_message:
134
+ rdoc_options: []
135
+ require_paths:
136
+ - lib
137
+ required_ruby_version: !ruby/object:Gem::Requirement
138
+ requirements:
139
+ - - ! '>='
140
+ - !ruby/object:Gem::Version
141
+ version: !binary |-
142
+ MA==
143
+ segments:
144
+ - 0
145
+ hash: 2
146
+ none: false
147
+ required_rubygems_version: !ruby/object:Gem::Requirement
148
+ requirements:
149
+ - - ! '>='
150
+ - !ruby/object:Gem::Version
151
+ version: !binary |-
152
+ MA==
153
+ none: false
154
+ requirements: []
155
+ rubyforge_project:
156
+ rubygems_version: 1.8.24
157
+ signing_key:
158
+ specification_version: 3
159
+ summary: JRuby webserver based on Vertx
160
+ test_files: []