jubilee 1.1.3-java → 2.0.0.alpha1-java
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Rakefile +1 -1
- data/examples/chatapp/Gemfile.lock +1 -1
- data/examples/chatapp/config.ru +1 -0
- data/jars/vertx-platform-2.1M3.jar +0 -0
- data/java/src/jubilee/JubileeService.java +2 -0
- data/java/src/org/jruby/jubilee/JubileeVerticle.java +67 -0
- data/java/src/org/jruby/jubilee/RackApplication.java +6 -6
- data/java/src/org/jruby/jubilee/RubyPlatformManager.java +102 -0
- data/java/src/org/jruby/jubilee/RubyServer.java +2 -1
- data/lib/jubilee/cli.rb +17 -7
- data/lib/jubilee/configuration.rb +6 -20
- data/lib/jubilee/jubilee.jar +0 -0
- data/lib/jubilee/server.rb +12 -4
- data/lib/jubilee/version.rb +4 -4
- data/lib/jubilee.rb +1 -0
- data/lib/rack/handler/jubilee.rb +1 -3
- data/spec/integration/basic_rack_spec.rb +3 -2
- data/spec/integration/basic_rails4_spec.rb +3 -2
- data/spec/integration/basic_sinatra_spec.rb +3 -1
- data/test/jubilee/test_configuration.rb +1 -17
- data/test/jubilee/test_rack_server.rb +10 -0
- data/test/jubilee/test_response.rb +0 -2
- data/test/jubilee/test_server.rb +6 -9
- metadata +7 -5
- data/java/src/org/jruby/jubilee/deploy/Starter.java +0 -26
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a77c3b1eb92007a671a033614f6e9d6d180a7a39
|
4
|
+
data.tar.gz: 35b271e8177901264b12c8de526237dcb5921e11
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d2d2f76613e7482d3244ffa51adc727459fd171ae3a710421733de3e6f2e5bb41a7f1da20b4113242a64453cf12b66b22ac2ab89269d92493b18a04ebc8565b9
|
7
|
+
data.tar.gz: 5822d5d9c68560a83b73194f2d9e23e6819c423eabd780cd770c52ffa1c5a0abda8c59abef3a7bec1972c809c7350e9607bfefcc4c4879518bdc932e4be84fd4
|
data/Rakefile
CHANGED
@@ -86,7 +86,7 @@ desc "Compile the extension, need jdk7 because vertx relies on it"
|
|
86
86
|
task :compile => [DEST_PATH, "#{DEST_PATH}/META-INF"] do |t|
|
87
87
|
ant.javac :srcdir => "java", :destdir => t.prerequisites.first,
|
88
88
|
:source => "1.7", :target => "1.7", :debug => true, :includeantruntime => false,
|
89
|
-
:classpath => "${java.class.path}:${sun.boot.class.path}:jars/vertx-core-2.1M3.jar:jars/netty-all-4.0.14.Final.jar:jars/jackson-core-2.2.2.jar:jars/jackson-databind-2.2.2.jar:jars/jackson-annotations-2.2.2.jar:jars/hazelcast-2.6.3.jar"
|
89
|
+
:classpath => "${java.class.path}:${sun.boot.class.path}:jars/vertx-core-2.1M3.jar:jars/netty-all-4.0.14.Final.jar:jars/jackson-core-2.2.2.jar:jars/jackson-databind-2.2.2.jar:jars/jackson-annotations-2.2.2.jar:jars/hazelcast-2.6.3.jar:jars/vertx-platform-2.1M3.jar"
|
90
90
|
end
|
91
91
|
|
92
92
|
desc "Copy META-INF"
|
data/examples/chatapp/config.ru
CHANGED
Binary file
|
@@ -2,6 +2,7 @@ package jubilee;
|
|
2
2
|
|
3
3
|
import org.jruby.Ruby;
|
4
4
|
import org.jruby.jubilee.RubyHttpServerResponse;
|
5
|
+
import org.jruby.jubilee.RubyPlatformManager;
|
5
6
|
import org.jruby.jubilee.RubyServer;
|
6
7
|
import org.jruby.jubilee.impl.RubyIORackInput;
|
7
8
|
import org.jruby.jubilee.impl.RubyNullIO;
|
@@ -15,6 +16,7 @@ public class JubileeService implements BasicLibraryService {
|
|
15
16
|
RubyHttpServerResponse.createHttpServerResponseClass(ruby);
|
16
17
|
RubyIORackInput.createIORackInputClass(ruby);
|
17
18
|
RubyNullIO.createNullIOClass(ruby);
|
19
|
+
RubyPlatformManager.createPlatformManagerClass(ruby);
|
18
20
|
return true;
|
19
21
|
}
|
20
22
|
}
|
@@ -0,0 +1,67 @@
|
|
1
|
+
package org.jruby.jubilee;
|
2
|
+
|
3
|
+
import org.jruby.Ruby;
|
4
|
+
import org.jruby.runtime.builtin.IRubyObject;
|
5
|
+
import org.vertx.java.core.Handler;
|
6
|
+
import org.vertx.java.core.http.HttpServer;
|
7
|
+
import org.vertx.java.core.http.HttpServerRequest;
|
8
|
+
import org.vertx.java.core.json.JsonArray;
|
9
|
+
import org.vertx.java.core.json.JsonObject;
|
10
|
+
import org.vertx.java.platform.Verticle;
|
11
|
+
import org.vertx.java.platform.impl.WrappedVertx;
|
12
|
+
|
13
|
+
import java.io.IOException;
|
14
|
+
|
15
|
+
/**
|
16
|
+
* Created by isaiah on 23/01/2014.
|
17
|
+
*/
|
18
|
+
public class JubileeVerticle extends Verticle {
|
19
|
+
private Ruby ruby;
|
20
|
+
|
21
|
+
@Override
|
22
|
+
public void start() {
|
23
|
+
JsonObject config = container.config();
|
24
|
+
HttpServer httpServer = vertx.createHttpServer();
|
25
|
+
ruby = config.getValue("ruby");
|
26
|
+
IRubyObject rackApplication;
|
27
|
+
final RackApplication app;
|
28
|
+
boolean ssl =config.getBoolean("ssl");
|
29
|
+
if (config.containsField("rackapp")) rackApplication = config.getValue("rackapp");
|
30
|
+
else {
|
31
|
+
String rackup = config.getString("rackup");
|
32
|
+
String rackScript = "require 'rack'\n" +
|
33
|
+
"require 'jubilee'\n" +
|
34
|
+
"app, _ = Rack::Builder.parse_file('" + rackup + "')\n";
|
35
|
+
if (!config.getBoolean("quiet") && config.getString("environment").equals("development")) {
|
36
|
+
rackScript += "logger = STDOUT\n" +
|
37
|
+
"app = Rack::CommonLogger.new(app, logger)\n";
|
38
|
+
}
|
39
|
+
rackScript += "Jubilee::Application.new(app)\n";
|
40
|
+
rackApplication = ruby.evalScriptlet(rackScript);
|
41
|
+
}
|
42
|
+
try {
|
43
|
+
app = new RackApplication((WrappedVertx) vertx, ruby.getCurrentContext(), rackApplication, ssl);
|
44
|
+
httpServer.setAcceptBacklog(10000);
|
45
|
+
httpServer.requestHandler(new Handler<HttpServerRequest>() {
|
46
|
+
public void handle(final HttpServerRequest req) {
|
47
|
+
app.call(req);
|
48
|
+
}
|
49
|
+
});
|
50
|
+
if (config.containsField("event_bus")) {
|
51
|
+
JsonArray allowAll = new JsonArray();
|
52
|
+
allowAll.add(new JsonObject());
|
53
|
+
vertx.createSockJSServer(httpServer).bridge(config.getObject("event_bus"), allowAll, allowAll);
|
54
|
+
}
|
55
|
+
if (ssl) httpServer.setSSL(true).setKeyStorePath(config.getString("keystore_path"))
|
56
|
+
.setKeyStorePassword(config.getString("keystore_password"));
|
57
|
+
httpServer.listen(config.getInteger("port"), config.getString("host"));
|
58
|
+
} catch (IOException e) {
|
59
|
+
container.logger().fatal("Failed to create RackApplication");
|
60
|
+
}
|
61
|
+
}
|
62
|
+
|
63
|
+
@Override
|
64
|
+
public void stop() {
|
65
|
+
this.ruby.tearDown(false);
|
66
|
+
}
|
67
|
+
}
|
@@ -18,6 +18,7 @@ import org.vertx.java.core.VoidHandler;
|
|
18
18
|
import org.vertx.java.core.buffer.Buffer;
|
19
19
|
import org.vertx.java.core.http.HttpServerRequest;
|
20
20
|
import org.vertx.java.core.impl.DefaultVertx;
|
21
|
+
import org.vertx.java.platform.impl.WrappedVertx;
|
21
22
|
|
22
23
|
import java.io.IOException;
|
23
24
|
import java.io.PrintWriter;
|
@@ -34,17 +35,17 @@ public class RackApplication {
|
|
34
35
|
private IRubyObject app;
|
35
36
|
private boolean ssl;
|
36
37
|
private Ruby runtime;
|
37
|
-
private
|
38
|
+
private WrappedVertx vertx;
|
38
39
|
private RubyClass rackIOInputClass;
|
39
40
|
private RubyClass httpServerResponseClass;
|
40
41
|
private RubyArray rackVersion;
|
41
42
|
private RubyNullIO nullio;
|
42
43
|
private RackEnvironment rackEnv;
|
43
44
|
|
44
|
-
public RackApplication(
|
45
|
+
public RackApplication(WrappedVertx vertx, ThreadContext context, IRubyObject app, boolean ssl) throws IOException {
|
45
46
|
this.app = app;
|
46
47
|
this.ssl = ssl;
|
47
|
-
this.vertx =
|
48
|
+
this.vertx = vertx;
|
48
49
|
this.runtime = context.runtime;
|
49
50
|
this.rackVersion = RubyArray.newArrayLight(runtime, RubyFixnum.one(runtime), RubyFixnum.four(runtime));
|
50
51
|
// Memorize the ruby classes
|
@@ -86,10 +87,9 @@ public class RackApplication {
|
|
86
87
|
Runnable task = new Runnable() {
|
87
88
|
@Override
|
88
89
|
public void run() {
|
89
|
-
// This is a different context, do NOT replace runtime.getCurrentContext()
|
90
|
-
// IRubyObject result = app.callMethod(runtime.getCurrentContext(), "call", env.getEnv());
|
91
90
|
try {
|
92
|
-
|
91
|
+
// This is a different context, do NOT replace runtime.getCurrentContext()
|
92
|
+
IRubyObject result = app.callMethod(runtime.getCurrentContext(), "call", rackEnv.getEnv(request, input, ssl));
|
93
93
|
RackResponse response = (RackResponse) JavaEmbedUtils.rubyToJava(runtime, result, RackResponse.class);
|
94
94
|
RubyHttpServerResponse resp = new RubyHttpServerResponse(runtime,
|
95
95
|
httpServerResponseClass,
|
@@ -0,0 +1,102 @@
|
|
1
|
+
package org.jruby.jubilee;
|
2
|
+
|
3
|
+
import org.jruby.*;
|
4
|
+
import org.jruby.anno.JRubyMethod;
|
5
|
+
import org.jruby.runtime.ObjectAllocator;
|
6
|
+
import org.jruby.runtime.ThreadContext;
|
7
|
+
import org.jruby.runtime.builtin.IRubyObject;
|
8
|
+
import org.vertx.java.core.AsyncResult;
|
9
|
+
import org.vertx.java.core.AsyncResultHandler;
|
10
|
+
import org.vertx.java.core.json.JsonObject;
|
11
|
+
import org.vertx.java.platform.PlatformLocator;
|
12
|
+
import org.vertx.java.platform.PlatformManager;
|
13
|
+
|
14
|
+
import java.util.HashMap;
|
15
|
+
import java.util.Map;
|
16
|
+
|
17
|
+
/**
|
18
|
+
* Created by isaiah on 23/01/2014.
|
19
|
+
*/
|
20
|
+
public class RubyPlatformManager extends RubyObject {
|
21
|
+
private PlatformManager pm;
|
22
|
+
|
23
|
+
public static void createPlatformManagerClass(Ruby runtime) {
|
24
|
+
RubyModule mJubilee = runtime.defineModule("Jubilee");
|
25
|
+
RubyClass serverClass = mJubilee.defineClassUnder("PlatformManager", runtime.getObject(), ALLOCATOR);
|
26
|
+
serverClass.defineAnnotatedMethods(RubyPlatformManager.class);
|
27
|
+
}
|
28
|
+
|
29
|
+
private static ObjectAllocator ALLOCATOR = new ObjectAllocator() {
|
30
|
+
public IRubyObject allocate(Ruby ruby, RubyClass rubyClass) {
|
31
|
+
return new RubyPlatformManager(ruby, rubyClass);
|
32
|
+
}
|
33
|
+
};
|
34
|
+
|
35
|
+
public RubyPlatformManager(Ruby ruby, RubyClass rubyClass) {
|
36
|
+
super(ruby, rubyClass);
|
37
|
+
}
|
38
|
+
|
39
|
+
@JRubyMethod
|
40
|
+
public IRubyObject initialize(ThreadContext context, IRubyObject config) {
|
41
|
+
RubyHash options = config.convertToHash();
|
42
|
+
pm = PlatformLocator.factory.createPlatformManager();
|
43
|
+
int ins = RubyNumeric.num2int(options.op_aref(context, RubySymbol.newSymbol(context.runtime, "instances")));
|
44
|
+
pm.deployVerticle("org.jruby.jubilee.JubileeVerticle", new JsonObject(parseOptions(options)),
|
45
|
+
context.runtime.getJRubyClassLoader().getURLs(), ins, null, new AsyncResultHandler<String>() {
|
46
|
+
@Override
|
47
|
+
public void handle(AsyncResult<String> result) {
|
48
|
+
if (result.succeeded()) {
|
49
|
+
// System.out.println("Deployment ID is " + result.result());
|
50
|
+
} else{
|
51
|
+
result.cause().printStackTrace();
|
52
|
+
}
|
53
|
+
}
|
54
|
+
});
|
55
|
+
return this;
|
56
|
+
}
|
57
|
+
|
58
|
+
@JRubyMethod
|
59
|
+
public IRubyObject stop(ThreadContext context) {
|
60
|
+
pm.stop();
|
61
|
+
return context.runtime.getNil();
|
62
|
+
}
|
63
|
+
|
64
|
+
private Map<String, Object> parseOptions(RubyHash options) {
|
65
|
+
Ruby runtime = options.getRuntime();
|
66
|
+
ThreadContext context = runtime.getCurrentContext();
|
67
|
+
RubySymbol port_k = runtime.newSymbol("Port");
|
68
|
+
RubySymbol host_k = runtime.newSymbol("Host");
|
69
|
+
RubySymbol ssl_k = runtime.newSymbol("ssl");
|
70
|
+
RubySymbol rack_app_k = runtime.newSymbol("rackapp");
|
71
|
+
RubySymbol rack_up_k = runtime.newSymbol("rackup");
|
72
|
+
RubySymbol ssl_keystore_k = runtime.newSymbol("ssl_keystore");
|
73
|
+
RubySymbol ssl_password_k = runtime.newSymbol("ssl_password");
|
74
|
+
RubySymbol eventbus_prefix_k = runtime.newSymbol("eventbus_prefix");
|
75
|
+
RubySymbol quiet_k = runtime.newSymbol("quiet");
|
76
|
+
RubySymbol environment_k = runtime.newSymbol("environment");
|
77
|
+
Map<String, Object> map = new HashMap<>();
|
78
|
+
map.put("host", options.op_aref(context, host_k).asJavaString());
|
79
|
+
map.put("port", RubyNumeric.num2int(options.op_aref(context, port_k)));
|
80
|
+
|
81
|
+
if (options.has_key_p(rack_up_k).isTrue())
|
82
|
+
map.put("rackup", options.op_aref(context, rack_up_k).asJavaString());
|
83
|
+
if (options.has_key_p(rack_app_k).isTrue())
|
84
|
+
map.put("rackapp", options.op_aref(context, rack_app_k));
|
85
|
+
map.put("quiet", options.containsKey(quiet_k) && options.op_aref(context, quiet_k).isTrue());
|
86
|
+
|
87
|
+
map.put("environment", options.op_aref(context, environment_k).asJavaString());
|
88
|
+
|
89
|
+
boolean ssl = options.op_aref(context, ssl_k).isTrue();
|
90
|
+
if (ssl) {
|
91
|
+
map.put("keystore_path", options.op_aref(context, ssl_keystore_k).asJavaString());
|
92
|
+
if (options.has_key_p(ssl_password_k).isTrue())
|
93
|
+
map.put("keystore_password", options.op_aref(context, ssl_password_k).asJavaString());
|
94
|
+
}
|
95
|
+
map.put("ssl", ssl);
|
96
|
+
if (options.has_key_p(eventbus_prefix_k).isTrue())
|
97
|
+
map.put("event_bus", options.op_aref(context, eventbus_prefix_k).asJavaString());
|
98
|
+
// This is a trick to put an Object into the config object
|
99
|
+
map.put("ruby", runtime);
|
100
|
+
return map;
|
101
|
+
}
|
102
|
+
}
|
@@ -13,6 +13,7 @@ import org.vertx.java.core.http.HttpServer;
|
|
13
13
|
import org.vertx.java.core.http.HttpServerRequest;
|
14
14
|
import org.vertx.java.core.json.JsonArray;
|
15
15
|
import org.vertx.java.core.json.JsonObject;
|
16
|
+
import org.vertx.java.platform.impl.WrappedVertx;
|
16
17
|
|
17
18
|
import java.io.IOException;
|
18
19
|
|
@@ -82,7 +83,7 @@ public class RubyServer extends RubyObject {
|
|
82
83
|
|
83
84
|
httpServer = vertx.createHttpServer();
|
84
85
|
try {
|
85
|
-
this.app = new RackApplication(vertx, context, app, this.ssl);
|
86
|
+
this.app = new RackApplication((WrappedVertx) vertx, context, app, this.ssl);
|
86
87
|
if (block.isGiven()) block.yieldSpecific(context, this);
|
87
88
|
} catch (IOException e) {
|
88
89
|
// noop
|
data/lib/jubilee/cli.rb
CHANGED
@@ -39,11 +39,16 @@ module Jubilee
|
|
39
39
|
`jubilee_d #{(@argv - ["-d", "--daemon"]).join(" ")}`
|
40
40
|
else
|
41
41
|
@config = Jubilee::Configuration.new(@options)
|
42
|
-
server = Jubilee::Server.new(
|
43
|
-
server.start
|
42
|
+
server = Jubilee::Server.new(nil, @config.options)
|
43
|
+
#server.start
|
44
|
+
thread = Thread.current
|
45
|
+
Signal.trap("INT") do
|
46
|
+
server.stop
|
47
|
+
puts "Jubilee is shutting down gracefully..."
|
48
|
+
thread.wakeup
|
49
|
+
end
|
44
50
|
puts "Jubilee is listening on port #{@config.options[:Port]}, press Ctrl+C to quit"
|
45
|
-
|
46
|
-
starter.block
|
51
|
+
sleep
|
47
52
|
end
|
48
53
|
end
|
49
54
|
|
@@ -53,6 +58,8 @@ module Jubilee
|
|
53
58
|
daemon: false,
|
54
59
|
ssl: false,
|
55
60
|
Port: 8080,
|
61
|
+
instances: 4,
|
62
|
+
quiet: false,
|
56
63
|
environment: ENV["RACK_ENV"] || "development"
|
57
64
|
}
|
58
65
|
@parser = OptionParser.new do |o|
|
@@ -68,18 +75,21 @@ module Jubilee
|
|
68
75
|
o.on "--dir DIR", "Change to DIR before starting" do |arg|
|
69
76
|
@options[:chdir] = arg
|
70
77
|
end
|
71
|
-
o.on "-p", "--port PORT", "
|
78
|
+
o.on "-p", "--port PORT", "Define which PORT the server should bind" do |arg|
|
72
79
|
@options[:Port] = arg.to_i
|
73
80
|
end
|
74
|
-
o.on "-b", "--host HOST", "
|
81
|
+
o.on "-b", "--host HOST", "Define which HOST the server should bind, default 0.0.0.0" do |arg|
|
75
82
|
@options[:Host] = arg
|
76
83
|
end
|
77
84
|
o.on "-e", "--environment ENV", "Rack environment" do |arg|
|
78
85
|
@options[:environment] = arg
|
79
86
|
end
|
87
|
+
o.on "-n", "--instances NUM", "Define how many instances of web servers to run" do |arg|
|
88
|
+
@options[:instances] = arg.to_i
|
89
|
+
end
|
80
90
|
o.separator ""
|
81
91
|
o.separator "SSL options:"
|
82
|
-
o.on "--ssl", "Enable SSL connection" do
|
92
|
+
o.on "--ssl", "Enable SSL connection" do
|
83
93
|
@options[:ssl] = true
|
84
94
|
end
|
85
95
|
o.on "--ssl-keystore PATH", "SSL keystore path" do |arg|
|
@@ -17,6 +17,7 @@ module Jubilee
|
|
17
17
|
|
18
18
|
reload
|
19
19
|
# initialize vertx as early as possible
|
20
|
+
# XXX vertx is managed by PlatformManager now
|
20
21
|
if chost = @options[:cluster_host]
|
21
22
|
if cport = @options[:cluster_port]
|
22
23
|
org.jruby.jubilee.vertx.JubileeVertx.init(cport.to_java(:int), chost.to_java)
|
@@ -30,16 +31,7 @@ module Jubilee
|
|
30
31
|
|
31
32
|
def reload
|
32
33
|
instance_eval(File.read(config_file), config_file) if config_file
|
33
|
-
|
34
|
-
|
35
|
-
def app
|
36
|
-
@app ||= load_rack_adapter(@options, &@block)
|
37
|
-
if !@options[:quiet] and @options[:environment] == "development"
|
38
|
-
logger = @options[:logger] || STDOUT
|
39
|
-
Rack::CommonLogger.new(@app, logger)
|
40
|
-
else
|
41
|
-
@app
|
42
|
-
end
|
34
|
+
load_rack_adapter(&@block)
|
43
35
|
end
|
44
36
|
|
45
37
|
# sets the host and port jubilee listens to +address+ may be an Integer port
|
@@ -124,18 +116,12 @@ module Jubilee
|
|
124
116
|
end
|
125
117
|
|
126
118
|
private
|
127
|
-
def load_rack_adapter(
|
119
|
+
def load_rack_adapter(&block)
|
128
120
|
if block
|
129
|
-
|
130
|
-
else
|
131
|
-
Dir.chdir options[:chdir] if options[:chdir]
|
132
|
-
if !File.exist?(rackup)
|
133
|
-
raise "Missing rackup file #{File.absolute_path(rackup)}"
|
134
|
-
end
|
135
|
-
inner_app, opts = Rack::Builder.parse_file(rackup)
|
136
|
-
@options.merge!(opts)
|
121
|
+
@options[:rackapp] = Rack::Builder.new(&block).to_app
|
137
122
|
end
|
138
|
-
|
123
|
+
Dir.chdir(@options[:chdir]) if @options[:chdir]
|
124
|
+
@options[:rackup] = rackup
|
139
125
|
end
|
140
126
|
|
141
127
|
def rackup
|
data/lib/jubilee/jubilee.jar
CHANGED
Binary file
|
data/lib/jubilee/server.rb
CHANGED
@@ -1,12 +1,20 @@
|
|
1
|
-
require 'rack/methodoverride'
|
2
1
|
module Jubilee
|
3
|
-
class Server <
|
2
|
+
class Server < PlatformManager
|
4
3
|
def initialize(app, opts = {})
|
5
|
-
options = {Host: "0.0.0.0", Port: 8080, ssl: false}.merge(opts)
|
4
|
+
options = {Host: "0.0.0.0", Port: 8080, ssl: false, instances: 1, environment: "development", quiet: true}.merge(opts)
|
6
5
|
if (options[:ssl]) && options[:ssl_keystore].nil?
|
7
6
|
raise ArgumentError, "Please provide a keystore for ssl"
|
8
7
|
end
|
9
|
-
|
8
|
+
# Rackup passes a string value
|
9
|
+
options[:Port] = options[:Port].to_i
|
10
|
+
# back compatible
|
11
|
+
if app
|
12
|
+
options[:rackapp] = Application.new(app)
|
13
|
+
end
|
14
|
+
super(options)
|
15
|
+
end
|
16
|
+
|
17
|
+
def start
|
10
18
|
end
|
11
19
|
end
|
12
20
|
end
|
data/lib/jubilee/version.rb
CHANGED
data/lib/jubilee.rb
CHANGED
@@ -4,6 +4,7 @@ require File.join(File.dirname(__FILE__), "../jars/jackson-annotations-2.2.2.jar
|
|
4
4
|
require File.join(File.dirname(__FILE__), "../jars/hazelcast-2.6.3.jar")
|
5
5
|
require File.join(File.dirname(__FILE__), "../jars/vertx-core-2.1M3.jar")
|
6
6
|
require File.join(File.dirname(__FILE__), "../jars/vertx-hazelcast-2.1M3.jar")
|
7
|
+
require File.join(File.dirname(__FILE__), "../jars/vertx-platform-2.1M3.jar")
|
7
8
|
require File.join(File.dirname(__FILE__), "../jars/netty-all-4.0.14.Final.jar")
|
8
9
|
|
9
10
|
require 'jubilee/jubilee.jar'
|
data/lib/rack/handler/jubilee.rb
CHANGED
@@ -4,12 +4,14 @@ feature "basic rack at non-root context" do
|
|
4
4
|
|
5
5
|
before(:all) do
|
6
6
|
configurator = Jubilee::Configuration.new(chdir: "#{apps_dir}/rack/basic")
|
7
|
-
@server = Jubilee::Server.new(
|
7
|
+
@server = Jubilee::Server.new(nil, configurator.options)
|
8
8
|
@server.start
|
9
|
+
sleep 0.1
|
9
10
|
end
|
10
11
|
|
11
12
|
after(:all) do
|
12
13
|
@server.stop
|
14
|
+
sleep 0.1
|
13
15
|
end
|
14
16
|
|
15
17
|
it "should work for basic requests" do
|
@@ -85,5 +87,4 @@ feature "basic rack at non-root context" do
|
|
85
87
|
response.body.should include("<div id='posted'>field=nothing</div>")
|
86
88
|
end
|
87
89
|
end
|
88
|
-
|
89
90
|
end
|
@@ -4,13 +4,14 @@ feature 'basic rails4 test' do
|
|
4
4
|
|
5
5
|
before(:all) do
|
6
6
|
configurator = Jubilee::Configuration.new(chdir: "#{apps_dir}/rails4/basic")
|
7
|
-
@server = Jubilee::Server.new(
|
7
|
+
@server = Jubilee::Server.new(nil, configurator.options)
|
8
8
|
@server.start
|
9
|
-
sleep
|
9
|
+
sleep 11
|
10
10
|
end
|
11
11
|
|
12
12
|
after(:all) do
|
13
13
|
@server.stop
|
14
|
+
sleep 0.1
|
14
15
|
end
|
15
16
|
|
16
17
|
it 'should do a basic get' do
|
@@ -4,12 +4,14 @@ feature "basic sinatra test" do
|
|
4
4
|
|
5
5
|
before(:all) do
|
6
6
|
configurator = Jubilee::Configuration.new(chdir: "#{apps_dir}/sinatra/basic")
|
7
|
-
@server = Jubilee::Server.new(
|
7
|
+
@server = Jubilee::Server.new(nil, configurator.options)
|
8
8
|
@server.start
|
9
|
+
sleep 1
|
9
10
|
end
|
10
11
|
|
11
12
|
after(:all) do
|
12
13
|
@server.stop
|
14
|
+
sleep 0.1
|
13
15
|
end
|
14
16
|
|
15
17
|
it "should work" do
|
@@ -15,22 +15,6 @@ class TestConfig < MiniTest::Unit::TestCase
|
|
15
15
|
Dir.chdir(@dir)
|
16
16
|
end
|
17
17
|
|
18
|
-
def test_load
|
19
|
-
@config = Jubilee::Configuration.new({rackup: "test/config/config.ru"})
|
20
|
-
assert_equal @resp, @config.app.call({})
|
21
|
-
end
|
22
|
-
|
23
|
-
def test_change_dir
|
24
|
-
@config = Jubilee::Configuration.new({chdir: "test/config"})
|
25
|
-
assert_equal @resp, @config.app.call({})
|
26
|
-
end
|
27
|
-
|
28
|
-
def test_customize_config_file
|
29
|
-
@config = Jubilee::Configuration.new({chdir: "test/config", rackup: "app.ru"})
|
30
|
-
resp = [200, {"Content-Type" => "text/plain"}, ["customized body"]]
|
31
|
-
assert_equal resp, @config.app.call({})
|
32
|
-
end
|
33
|
-
|
34
18
|
def test_config_invalid
|
35
19
|
@tmp.syswrite(%q(abcd "helloword"))
|
36
20
|
assert_raises(NoMethodError) do
|
@@ -82,7 +66,7 @@ class TestConfig < MiniTest::Unit::TestCase
|
|
82
66
|
#end
|
83
67
|
|
84
68
|
def test_config_file_working_directory
|
85
|
-
@tmp.syswrite(%q(working_directory "chatapp"))
|
69
|
+
@tmp.syswrite(%q(working_directory "examples/chatapp"))
|
86
70
|
options = Jubilee::Configuration.new(config_file: @tmp.path).options
|
87
71
|
assert_match(/chatapp/, options[:chdir])
|
88
72
|
end
|
@@ -75,6 +75,7 @@ class TestRackServer < MiniTest::Unit::TestCase
|
|
75
75
|
@server = Jubilee::Server.new @checker
|
76
76
|
|
77
77
|
@server.start
|
78
|
+
sleep 0.5
|
78
79
|
|
79
80
|
big = "x" * (1024 * 16)
|
80
81
|
|
@@ -114,6 +115,7 @@ class TestRackServer < MiniTest::Unit::TestCase
|
|
114
115
|
input = nil
|
115
116
|
@server = Jubilee::Server.new(lambda { |env| input = env; @simple.call(env) })
|
116
117
|
@server.start
|
118
|
+
sleep 0.1
|
117
119
|
|
118
120
|
hit(['http://127.0.0.1:8080/test/a/b/c?foo=bar'])
|
119
121
|
|
@@ -125,6 +127,7 @@ class TestRackServer < MiniTest::Unit::TestCase
|
|
125
127
|
input = nil
|
126
128
|
@server = Jubilee::Server.new(lambda { |env| input = env; @simple.call(env) })
|
127
129
|
@server.start
|
130
|
+
sleep 0.1
|
128
131
|
|
129
132
|
req = Net::HTTP::Post::Multipart.new("/", "foo" => "bar")
|
130
133
|
Net::HTTP.start('localhost', 8080) do |http|
|
@@ -143,4 +146,11 @@ class TestRackServer < MiniTest::Unit::TestCase
|
|
143
146
|
res = hit(['http://127.0.0.1:8080/test'])
|
144
147
|
assert_kind_of Net::HTTPServerError, res[0]
|
145
148
|
end
|
149
|
+
|
150
|
+
# GH_9
|
151
|
+
def test_string_port_value
|
152
|
+
@server = Jubilee::Server.new(@simple, {Port: "3000"})
|
153
|
+
# assert_wont_raise_anything
|
154
|
+
@server.start
|
155
|
+
end
|
146
156
|
end
|
@@ -188,7 +188,6 @@ class TestResponse < MiniTest::Unit::TestCase
|
|
188
188
|
|
189
189
|
|
190
190
|
def test_two_requests_in_one_chunk
|
191
|
-
@server.persistent_timeout = 3
|
192
191
|
|
193
192
|
req = @valid_request.to_s
|
194
193
|
req << "GET /second HTTP/1.1\r\nHost: test.com\r\nContent-Type: text/plain\r\n\r\n"
|
@@ -205,7 +204,6 @@ class TestResponse < MiniTest::Unit::TestCase
|
|
205
204
|
end
|
206
205
|
|
207
206
|
def test_second_request_not_in_first_req_body
|
208
|
-
@server.persistent_timeout = 3
|
209
207
|
|
210
208
|
req = @valid_request.to_s
|
211
209
|
req << "GET /second HTTP/1.1\r\nHost: test.com\r\nContent-Type: text/plain\r\n\r\n"
|
data/test/jubilee/test_server.rb
CHANGED
@@ -9,13 +9,14 @@ class TestJubileeServer < MiniTest::Unit::TestCase
|
|
9
9
|
|
10
10
|
def teardown
|
11
11
|
@server.stop if @server
|
12
|
+
sleep 0.1
|
12
13
|
end
|
13
14
|
|
14
15
|
def test_server_lambda
|
15
16
|
app = lambda {|env| [200, {"Content-Type" => "text/plain"}, ["http"]] }
|
16
17
|
@server = Jubilee::Server.new(app)
|
17
18
|
@server.start
|
18
|
-
sleep 0.
|
19
|
+
sleep 0.5
|
19
20
|
|
20
21
|
http, body = Net::HTTP.new(@host, @port), nil
|
21
22
|
http.start do
|
@@ -28,10 +29,10 @@ class TestJubileeServer < MiniTest::Unit::TestCase
|
|
28
29
|
end
|
29
30
|
|
30
31
|
def test_server_embedded
|
31
|
-
config = Jubilee::Configuration.new(rackup: File.
|
32
|
-
@server = Jubilee::Server.new(config.
|
32
|
+
config = Jubilee::Configuration.new(rackup: File.expand_path("../../config/config.ru", __FILE__))
|
33
|
+
@server = Jubilee::Server.new(nil, config.options)
|
33
34
|
@server.start
|
34
|
-
sleep 0.
|
35
|
+
sleep 0.5
|
35
36
|
http, body = Net::HTTP.new(@host, @port), nil
|
36
37
|
http.start do
|
37
38
|
req = Net::HTTP::Get.new "/", {}
|
@@ -42,17 +43,13 @@ class TestJubileeServer < MiniTest::Unit::TestCase
|
|
42
43
|
assert_equal "embedded app", body
|
43
44
|
end
|
44
45
|
|
45
|
-
def test_large_post_body
|
46
|
-
skip
|
47
|
-
end
|
48
|
-
|
49
46
|
def test_url_scheme_for_https
|
50
47
|
app = lambda { |env| [200, {}, [env['rack.url_scheme']]] }
|
51
48
|
@server = Jubilee::Server.new(app, {port:@port, ssl:true,
|
52
49
|
ssl_keystore: File.join(File.dirname(__FILE__), "../../examples/keystore.jks"),
|
53
50
|
ssl_password: "hellojubilee"})
|
54
51
|
@server.start
|
55
|
-
sleep 0.
|
52
|
+
sleep 0.5
|
56
53
|
http = Net::HTTP.new @host, @port
|
57
54
|
http.use_ssl = true
|
58
55
|
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jubilee
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0.alpha1
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- Isaiah Peng
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-01-
|
11
|
+
date: 2014-01-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -96,18 +96,20 @@ files:
|
|
96
96
|
- jars/netty-all-4.0.14.Final.jar
|
97
97
|
- jars/vertx-core-2.1M3.jar
|
98
98
|
- jars/vertx-hazelcast-2.1M3.jar
|
99
|
+
- jars/vertx-platform-2.1M3.jar
|
99
100
|
- java/resources/META-INF/services/org.vertx.java.core.spi.cluster.ClusterManagerFactory
|
100
101
|
- java/resources/default-cluster.xml
|
101
102
|
- java/src/jubilee/JubileeService.java
|
102
103
|
- java/src/org/jruby/jubilee/Const.java
|
104
|
+
- java/src/org/jruby/jubilee/JubileeVerticle.java
|
103
105
|
- java/src/org/jruby/jubilee/RackApplication.java
|
104
106
|
- java/src/org/jruby/jubilee/RackEnvironment.java
|
105
107
|
- java/src/org/jruby/jubilee/RackEnvironmentHash.java
|
106
108
|
- java/src/org/jruby/jubilee/RackInput.java
|
107
109
|
- java/src/org/jruby/jubilee/RackResponse.java
|
108
110
|
- java/src/org/jruby/jubilee/RubyHttpServerResponse.java
|
111
|
+
- java/src/org/jruby/jubilee/RubyPlatformManager.java
|
109
112
|
- java/src/org/jruby/jubilee/RubyServer.java
|
110
|
-
- java/src/org/jruby/jubilee/deploy/Starter.java
|
111
113
|
- java/src/org/jruby/jubilee/impl/RubyIORackInput.java
|
112
114
|
- java/src/org/jruby/jubilee/impl/RubyNullIO.java
|
113
115
|
- java/src/org/jruby/jubilee/utils/RubyHelper.java
|
@@ -229,9 +231,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
229
231
|
version: '0'
|
230
232
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
231
233
|
requirements:
|
232
|
-
- - '
|
234
|
+
- - '>'
|
233
235
|
- !ruby/object:Gem::Version
|
234
|
-
version:
|
236
|
+
version: 1.3.1
|
235
237
|
requirements: []
|
236
238
|
rubyforge_project:
|
237
239
|
rubygems_version: 2.1.9
|
@@ -1,26 +0,0 @@
|
|
1
|
-
package org.jruby.jubilee.deploy;
|
2
|
-
|
3
|
-
import java.util.concurrent.CountDownLatch;
|
4
|
-
|
5
|
-
/**
|
6
|
-
* Created with IntelliJ IDEA.
|
7
|
-
* User: isaiah
|
8
|
-
* Date: 12/3/12
|
9
|
-
* Time: 7:37 PM
|
10
|
-
*/
|
11
|
-
public class Starter {
|
12
|
-
private CountDownLatch stopLatch = new CountDownLatch(1);
|
13
|
-
|
14
|
-
public void block() {
|
15
|
-
while(true) {
|
16
|
-
try {
|
17
|
-
stopLatch.await();
|
18
|
-
break;
|
19
|
-
} catch (InterruptedException ignore) {}
|
20
|
-
}
|
21
|
-
}
|
22
|
-
|
23
|
-
public void unblock() {
|
24
|
-
stopLatch.countDown();
|
25
|
-
}
|
26
|
-
}
|