Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

Let Heroku decide which http port to use

lucciomanb57a06d88e2e
diff --git a/Procfile b/Procfile
index c80972424..65a9880e6 100755
--- a/Procfile
+++ b/Procfile
@@ -1 +1 @@
-web: java $JAVA_OPTS -classpath target/classes:lib/* net.yacy.yacy
\ No newline at end of file
+web: java $JAVA_OPTS -Dhttp.port=$PORT -classpath target/classes:lib/* net.yacy.yacy
\ No newline at end of file
diff --git a/source/net/yacy/server/serverSwitch.java b/source/net/yacy/server/serverSwitch.java
index 02fe4443e..0f3bbcbf0 100644
--- a/source/net/yacy/server/serverSwitch.java
+++ b/source/net/yacy/server/serverSwitch.java
@@ -229,6 +229,15 @@ public class serverSwitch {
*/
public int getLocalPort() {
+ /* A system property "http.port" may override configuration
+ * This is useful when running YaCy inside a container manager such as Heroku which decide which http port to use */
+ String systemDefinedPort = System.getProperty("http.port");
+ if(systemDefinedPort != null) {
+ try {
+ return Integer.parseInt(systemDefinedPort);
+ } catch(NumberFormatException e) {
+ }
+ }
return getConfigInt("port", 8090);
}