Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add --bind to allow users to specity the address to bind to.

Defaults to 0.0.0.0 just like before.  This closes #174.

Signed-off-by: Benoit Sigoure <tsunanet@gmail.com>
  • Loading branch information...
commit 16d6c5f8796433d94fe7ba76822595075aae6593 1 parent b874fe5
@isavin isavin authored tsuna committed
Showing with 9 additions and 1 deletion.
  1. +9 −1 src/tools/TSDMain.java
View
10 src/tools/TSDMain.java
@@ -13,6 +13,7 @@
package net.opentsdb.tools;
import java.io.File;
+import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.util.concurrent.Executors;
@@ -91,6 +92,7 @@ public static void main(String[] args) {
final ArgP argp = new ArgP();
CliOptions.addCommon(argp);
argp.addOption("--port", "NUM", "TCP port to listen on.");
+ argp.addOption("--bind", "ADDR", "Address to bind to (default: 0.0.0.0).");
argp.addOption("--staticroot", "PATH",
"Web root from which to serve static files (/s URLs).");
argp.addOption("--cachedir", "PATH",
@@ -154,8 +156,14 @@ public static void main(String[] args) {
server.setOption("child.keepAlive", true);
server.setOption("reuseAddress", true);
+ // null is interpreted as the wildcard address.
+ InetAddress bindAddress = null;
+ if (argp.has("--bind")) {
+ bindAddress = InetAddress.getByName(argp.get("--bind"));
+ }
+
final InetSocketAddress addr =
- new InetSocketAddress(Integer.parseInt(argp.get("--port")));
+ new InetSocketAddress(bindAddress, Integer.parseInt(argp.get("--port")));
server.bind(addr);
log.info("Ready to serve on " + addr);
} catch (Throwable e) {
Please sign in to comment.
Something went wrong with that request. Please try again.