blob: 9efca4636aa976861730cc5665553bdfdf56f71a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
package moe.yuuta.dn42peering.agent;
import io.vertx.core.*;
import io.vertx.core.impl.logging.Logger;
import io.vertx.core.impl.logging.LoggerFactory;
import io.vertx.core.json.JsonObject;
import moe.yuuta.dn42peering.agent.grpc.RPCVerticle;
import javax.annotation.Nonnull;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.Arrays;
public class Main {
public static void main(@Nonnull String... args) throws Throwable {
if(args.length != 1) {
System.err.println("Usage: agent <path/to/config.json>");
System.exit(64);
return;
}
System.setProperty("vertx.logger-delegate-factory-class-name",
"io.vertx.core.logging.JULLogDelegateFactory");
final InputStream in = new FileInputStream(args[0]);
final JsonObject config = new JsonObject(IOUtils.read(in));
in.close();
final Vertx vertx = Vertx.vertx(new VertxOptions());
final DeploymentOptions options = new DeploymentOptions()
.setConfig(config)
.setInstances(1);
Logger logger = LoggerFactory.getLogger("Main");
CompositeFuture.all(Arrays.asList(
Future.<String>future(f -> vertx.deployVerticle(RPCVerticle.class.getName(), options, f))
)).onComplete(res -> {
if (res.succeeded()) {
logger.info("The server started.");
} else {
logger.error("Cannot deploy the server.", res.cause());
}
});
}
}
|