From ee3701a18c87dbc5772d14f258495f9350b90b2d Mon Sep 17 00:00:00 2001 From: snoop Date: Fri, 12 May 2017 11:27:18 +0900 Subject: [PATCH] added parameter : port --- src/main/java/com/loafle/overflow/Server.java | 15 ++++++++++++--- src/test/java/com/loafle/overflow/ServerTest.java | 2 +- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/loafle/overflow/Server.java b/src/main/java/com/loafle/overflow/Server.java index 2d9146d..e115648 100644 --- a/src/main/java/com/loafle/overflow/Server.java +++ b/src/main/java/com/loafle/overflow/Server.java @@ -57,9 +57,9 @@ public class Server { return bos.toByteArray(); } - public void start() throws IOException { + public void start(int port) throws IOException { /* The port on which the server should run */ - int port = 50052; +// int port = 50052; server = ServerBuilder.forPort(port) .addService(new ConfigImpl()) .addService(new DataImpl()) @@ -209,8 +209,17 @@ public class Server { * Main launches the server from the command line. */ public static void main(String[] args) throws IOException, InterruptedException { + + if(args.length <= 0) { + System.out.println("Port args"); + System.out.println("first parameter is Port Number"); + return; + } + + int port = Integer.valueOf(args[0]); + final Server server = new Server(); - server.start(); + server.start(port); server.blockUntilShutdown(); } } diff --git a/src/test/java/com/loafle/overflow/ServerTest.java b/src/test/java/com/loafle/overflow/ServerTest.java index 8fa5806..3d09168 100644 --- a/src/test/java/com/loafle/overflow/ServerTest.java +++ b/src/test/java/com/loafle/overflow/ServerTest.java @@ -39,7 +39,7 @@ public class ServerTest { public void setUp() throws Exception { server = new Server(); server.addDelegate(Crawlers.REDIS.name(),new TestCrawlerImpl()); - server.start(); + server.start(50052); } @After