From 74b598fc0297460f0bf663da2f5002f08738febc Mon Sep 17 00:00:00 2001 From: Charlie Groves Date: Tue, 22 Mar 2011 07:09:43 +0000 Subject: [PATCH] Add a main to PolicyServer that binds on the master port by default git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@6541 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- .../java/com/threerings/nio/PolicyServer.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/main/java/com/threerings/nio/PolicyServer.java b/src/main/java/com/threerings/nio/PolicyServer.java index f407d5b49..a7fe6a894 100644 --- a/src/main/java/com/threerings/nio/PolicyServer.java +++ b/src/main/java/com/threerings/nio/PolicyServer.java @@ -44,6 +44,24 @@ import static com.threerings.NaryaLog.log; @Singleton public class PolicyServer extends ConnectionManager { + public static void main (String[] args) + { + int port = MASTER_PORT; + if (args.length > 0) { + port = Integer.parseInt(args[0]); + } + PolicyServer server = null; + try { + server = new PolicyServer(new Lifecycle()); + } catch (IOException e) { + System.err.println("Failed to create policy server!"); + e.printStackTrace(System.err); + System.exit(1); + } + server.init(port); + } + + @Inject public PolicyServer (Lifecycle cycle) throws IOException @@ -84,6 +102,7 @@ public class PolicyServer extends ConnectionManager super.willStart(); if (!_acceptor.bind()) { log.warning("Policy server failed to bind!"); + shutdown(); } }