Skip to content

armgit / nutch

Public Imported from GitHub
0

Apache Nutch is an extensible and scalable web crawler

- fix for NUTCH-1976 Allow Users to Set Hostname for Server contributed by Tyler Palsulich.

Chris Mattmann4faa40e36639
diff --git a/CHANGES.txt b/CHANGES.txt
index 123bf8467..d55906289 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -2,6 +2,8 @@ Nutch Change Log
Nutch Current Development 1.10-SNAPSHOT
+* NUTCH-1976 Allow Users to Set Hostname for Server (Tyler Palsulich via mattmann)
+
* NUTCH-1941 Optional rolling http.agent.name's (Asitang Mishra, lewismc via snagel)
* NUTCH-1959 Improving CommonCrawlFormat implementations (Giuseppe Totaro via mattmann)
diff --git a/src/java/org/apache/nutch/service/NutchServer.java b/src/java/org/apache/nutch/service/NutchServer.java
index dbfd355a2..d89f3ee4f 100644
--- a/src/java/org/apache/nutch/service/NutchServer.java
+++ b/src/java/org/apache/nutch/service/NutchServer.java
@@ -49,9 +49,11 @@ public class NutchServer {
private static final int JOB_CAPACITY = 100;
private static Integer port = DEFAULT_PORT;
+ private static String host = LOCALHOST;
private static final String CMD_HELP = "help";
private static final String CMD_PORT = "port";
+ private static final String CMD_HOST = "host";
private long started;
private boolean running;
@@ -88,9 +90,9 @@ public class NutchServer {
}
private void start() {
- LOG.info("Starting NutchServer on port: {} ...",port);
+ LOG.info("Starting NutchServer on {}:{} ...", host, port);
try{
- String address = "http://" + LOCALHOST + ":" + port;
+ String address = "http://" + host + ":" + port;
sf.setAddress(address);
sf.create();
}catch(Exception e){
@@ -99,8 +101,8 @@ public class NutchServer {
started = System.currentTimeMillis();
running = true;
- LOG.info("Started Nutch Server on port {} at {}", port, started);
- System.out.println("Started Nutch Server on port " + port + " at " + started);
+ LOG.info("Started Nutch Server on {}:{} at {}", host, port, started);
+ System.out.println("Started Nutch Server on " + host + ":" + port + " at " + started);
}
public List<Class<?>> getClasses() {
@@ -134,6 +136,11 @@ public class NutchServer {
if (commandLine.hasOption(CMD_PORT)) {
port = Integer.parseInt(commandLine.getOptionValue(CMD_PORT));
}
+
+ if (commandLine.hasOption(CMD_HOST)) {
+ host = commandLine.getOptionValue(CMD_HOST);
+ }
+
startServer();
}
@@ -147,6 +154,12 @@ public class NutchServer {
OptionBuilder.hasOptionalArg();
OptionBuilder.withDescription("The port to run the Nutch Server. Default port 8081");
options.addOption(OptionBuilder.create(CMD_PORT));
+
+ OptionBuilder.withArgName("host");
+ OptionBuilder.hasOptionalArg();
+ OptionBuilder.withDescription("The host to bind the Nutch Server to. Default is localhost.");
+ options.addOption(OptionBuilder.create(CMD_PORT));
+
return options;
}