mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Revert "Merge pull request #125 from overleaf/spd-revert-jetty-changes"
This reverts commit 9c324c378c46aa8b4b14e529e90ad9cbfca969cd, reversing changes made to 63ccd609405952aa8749299c8a5cf7895f14a1bd.
This commit is contained in:
parent
2e8c1da85a
commit
f8f60eabad
9 changed files with 46 additions and 3 deletions
|
@ -1,5 +1,7 @@
|
||||||
{
|
{
|
||||||
"port": ${GIT_BRIDGE_PORT:-8000},
|
"port": ${GIT_BRIDGE_PORT:-8000},
|
||||||
|
"bindIp": "${GIT_BRIDGE_BIND_IP:-0.0.0.0}",
|
||||||
|
"idleTimeout": ${GIT_BRIDGE_IDLE_TIMEOUT:-600000},
|
||||||
"rootGitDirectory": "${GIT_BRIDGE_ROOT_DIR:-/tmp/wlgb}",
|
"rootGitDirectory": "${GIT_BRIDGE_ROOT_DIR:-/tmp/wlgb}",
|
||||||
"apiBaseUrl": "${GIT_BRIDGE_API_BASE_URL:-https://localhost/api/v0}",
|
"apiBaseUrl": "${GIT_BRIDGE_API_BASE_URL:-https://localhost/api/v0}",
|
||||||
"postbackBaseUrl": "${GIT_BRIDGE_POSTBACK_BASE_URL:-https://localhost}",
|
"postbackBaseUrl": "${GIT_BRIDGE_POSTBACK_BASE_URL:-https://localhost}",
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
{
|
{
|
||||||
"port": 8080,
|
"port": 8080,
|
||||||
|
"bindIp": "127.0.0.1",
|
||||||
|
"idleTimeout": 60000,
|
||||||
"rootGitDirectory": "/tmp/wlgb",
|
"rootGitDirectory": "/tmp/wlgb",
|
||||||
"apiBaseUrl": "https://localhost/api/v0",
|
"apiBaseUrl": "https://localhost/api/v0",
|
||||||
"postbackBaseUrl": "https://localhost",
|
"postbackBaseUrl": "https://localhost",
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
{
|
{
|
||||||
"port": 8000,
|
"port": 8000,
|
||||||
|
"bindIp": "0.0.0.0",
|
||||||
|
"idleTimeout": 600000,
|
||||||
"rootGitDirectory": "/tmp/wlgb",
|
"rootGitDirectory": "/tmp/wlgb",
|
||||||
"apiBaseUrl": "http://v2.overleaf.test:4000/api/v0",
|
"apiBaseUrl": "http://v2.overleaf.test:4000/api/v0",
|
||||||
"postbackBaseUrl": "http://git-bridge:8000",
|
"postbackBaseUrl": "http://git-bridge:8000",
|
||||||
|
|
|
@ -76,13 +76,13 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.eclipse.jetty</groupId>
|
<groupId>org.eclipse.jetty</groupId>
|
||||||
<artifactId>jetty-servlet</artifactId>
|
<artifactId>jetty-servlet</artifactId>
|
||||||
<version>9.4.8.v20171121</version>
|
<version>9.4.38.v20210224</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- https://mvnrepository.com/artifact/org.eclipse.jetty/jetty-server -->
|
<!-- https://mvnrepository.com/artifact/org.eclipse.jetty/jetty-server -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.eclipse.jetty</groupId>
|
<groupId>org.eclipse.jetty</groupId>
|
||||||
<artifactId>jetty-server</artifactId>
|
<artifactId>jetty-server</artifactId>
|
||||||
<version>9.4.8.v20171121</version>
|
<version>9.4.38.v20210224</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
|
<!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
@ -24,6 +24,8 @@ public class Config implements JSONSource {
|
||||||
static Config asSanitised(Config config) {
|
static Config asSanitised(Config config) {
|
||||||
return new Config(
|
return new Config(
|
||||||
config.port,
|
config.port,
|
||||||
|
config.bindIp,
|
||||||
|
config.idleTimeout,
|
||||||
config.rootGitDirectory,
|
config.rootGitDirectory,
|
||||||
config.apiBaseURL,
|
config.apiBaseURL,
|
||||||
config.postbackURL,
|
config.postbackURL,
|
||||||
|
@ -37,6 +39,8 @@ public class Config implements JSONSource {
|
||||||
}
|
}
|
||||||
|
|
||||||
private int port;
|
private int port;
|
||||||
|
private String bindIp;
|
||||||
|
private int idleTimeout;
|
||||||
private String rootGitDirectory;
|
private String rootGitDirectory;
|
||||||
private String apiBaseURL;
|
private String apiBaseURL;
|
||||||
private String postbackURL;
|
private String postbackURL;
|
||||||
|
@ -64,6 +68,8 @@ public class Config implements JSONSource {
|
||||||
|
|
||||||
public Config(
|
public Config(
|
||||||
int port,
|
int port,
|
||||||
|
String bindIp,
|
||||||
|
int idleTimeout,
|
||||||
String rootGitDirectory,
|
String rootGitDirectory,
|
||||||
String apiBaseURL,
|
String apiBaseURL,
|
||||||
String postbackURL,
|
String postbackURL,
|
||||||
|
@ -75,6 +81,8 @@ public class Config implements JSONSource {
|
||||||
int sqliteHeapLimitBytes
|
int sqliteHeapLimitBytes
|
||||||
) {
|
) {
|
||||||
this.port = port;
|
this.port = port;
|
||||||
|
this.bindIp = bindIp;
|
||||||
|
this.idleTimeout = idleTimeout;
|
||||||
this.rootGitDirectory = rootGitDirectory;
|
this.rootGitDirectory = rootGitDirectory;
|
||||||
this.apiBaseURL = apiBaseURL;
|
this.apiBaseURL = apiBaseURL;
|
||||||
this.postbackURL = postbackURL;
|
this.postbackURL = postbackURL;
|
||||||
|
@ -90,6 +98,8 @@ public class Config implements JSONSource {
|
||||||
public void fromJSON(JsonElement json) {
|
public void fromJSON(JsonElement json) {
|
||||||
JsonObject configObject = json.getAsJsonObject();
|
JsonObject configObject = json.getAsJsonObject();
|
||||||
port = getElement(configObject, "port").getAsInt();
|
port = getElement(configObject, "port").getAsInt();
|
||||||
|
bindIp = getElement(configObject, "bindIp").getAsString();
|
||||||
|
idleTimeout = getElement(configObject, "idleTimeout").getAsInt();
|
||||||
rootGitDirectory = getElement(
|
rootGitDirectory = getElement(
|
||||||
configObject,
|
configObject,
|
||||||
"rootGitDirectory"
|
"rootGitDirectory"
|
||||||
|
@ -131,6 +141,14 @@ public class Config implements JSONSource {
|
||||||
return port;
|
return port;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getBindIp() {
|
||||||
|
return bindIp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getIdleTimeout() {
|
||||||
|
return idleTimeout;
|
||||||
|
}
|
||||||
|
|
||||||
public String getRootGitDirectory() {
|
public String getRootGitDirectory() {
|
||||||
return rootGitDirectory;
|
return rootGitDirectory;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package uk.ac.ic.wlgitbridge.server;
|
||||||
|
|
||||||
import org.eclipse.jetty.server.Handler;
|
import org.eclipse.jetty.server.Handler;
|
||||||
import org.eclipse.jetty.server.Server;
|
import org.eclipse.jetty.server.Server;
|
||||||
|
import org.eclipse.jetty.server.ServerConnector;
|
||||||
import org.eclipse.jetty.server.handler.*;
|
import org.eclipse.jetty.server.handler.*;
|
||||||
import org.eclipse.jetty.servlet.FilterHolder;
|
import org.eclipse.jetty.servlet.FilterHolder;
|
||||||
import org.eclipse.jetty.servlet.ServletContextHandler;
|
import org.eclipse.jetty.servlet.ServletContextHandler;
|
||||||
|
@ -72,7 +73,7 @@ public class GitBridgeServer {
|
||||||
swapStore,
|
swapStore,
|
||||||
snapshotApi
|
snapshotApi
|
||||||
);
|
);
|
||||||
jettyServer = new Server(port);
|
jettyServer = new Server();
|
||||||
configureJettyServer(config, repoStore, snapshotApi);
|
configureJettyServer(config, repoStore, snapshotApi);
|
||||||
apiBaseURL = config.getAPIBaseURL();
|
apiBaseURL = config.getAPIBaseURL();
|
||||||
SnapshotAPIRequest.setBaseURL(apiBaseURL);
|
SnapshotAPIRequest.setBaseURL(apiBaseURL);
|
||||||
|
@ -114,6 +115,12 @@ public class GitBridgeServer {
|
||||||
RepoStore repoStore,
|
RepoStore repoStore,
|
||||||
SnapshotApi snapshotApi
|
SnapshotApi snapshotApi
|
||||||
) throws ServletException {
|
) throws ServletException {
|
||||||
|
ServerConnector connector = new ServerConnector(this.jettyServer);
|
||||||
|
connector.setPort(config.getPort());
|
||||||
|
connector.setHost(config.getBindIp());
|
||||||
|
connector.setIdleTimeout(config.getIdleTimeout());
|
||||||
|
this.jettyServer.addConnector(connector);
|
||||||
|
|
||||||
HandlerCollection handlers = new HandlerList();
|
HandlerCollection handlers = new HandlerList();
|
||||||
handlers.addHandler(initApiHandler());
|
handlers.addHandler(initApiHandler());
|
||||||
handlers.addHandler(initBaseHandler());
|
handlers.addHandler(initBaseHandler());
|
||||||
|
|
|
@ -1063,6 +1063,8 @@ public class WLGitBridgeIntegrationTest {
|
||||||
String cfgStr =
|
String cfgStr =
|
||||||
"{\n" +
|
"{\n" +
|
||||||
" \"port\": " + port + ",\n" +
|
" \"port\": " + port + ",\n" +
|
||||||
|
" \"bindIp\": \"127.0.0.1\",\n" +
|
||||||
|
" \"idleTimeout\": 30000,\n" +
|
||||||
" \"rootGitDirectory\": \"" +
|
" \"rootGitDirectory\": \"" +
|
||||||
wlgb.getAbsolutePath() +
|
wlgb.getAbsolutePath() +
|
||||||
"\",\n" +
|
"\",\n" +
|
||||||
|
|
|
@ -16,6 +16,8 @@ public class ConfigTest {
|
||||||
public void testConstructWithOauth() {
|
public void testConstructWithOauth() {
|
||||||
Reader reader = new StringReader("{\n" +
|
Reader reader = new StringReader("{\n" +
|
||||||
" \"port\": 80,\n" +
|
" \"port\": 80,\n" +
|
||||||
|
" \"bindIp\": \"127.0.0.1\",\n" +
|
||||||
|
" \"idleTimeout\": 30000,\n" +
|
||||||
" \"rootGitDirectory\": \"/var/wlgb/git\",\n" +
|
" \"rootGitDirectory\": \"/var/wlgb/git\",\n" +
|
||||||
" \"apiBaseUrl\": \"http://127.0.0.1:60000/api/v0\",\n" +
|
" \"apiBaseUrl\": \"http://127.0.0.1:60000/api/v0\",\n" +
|
||||||
" \"postbackBaseUrl\": \"http://127.0.0.1\",\n" +
|
" \"postbackBaseUrl\": \"http://127.0.0.1\",\n" +
|
||||||
|
@ -42,6 +44,8 @@ public class ConfigTest {
|
||||||
public void testConstructWithoutOauth() {
|
public void testConstructWithoutOauth() {
|
||||||
Reader reader = new StringReader("{\n" +
|
Reader reader = new StringReader("{\n" +
|
||||||
" \"port\": 80,\n" +
|
" \"port\": 80,\n" +
|
||||||
|
" \"bindIp\": \"127.0.0.1\",\n" +
|
||||||
|
" \"idleTimeout\": 30000,\n" +
|
||||||
" \"rootGitDirectory\": \"/var/wlgb/git\",\n" +
|
" \"rootGitDirectory\": \"/var/wlgb/git\",\n" +
|
||||||
" \"apiBaseUrl\": \"http://127.0.0.1:60000/api/v0\",\n" +
|
" \"apiBaseUrl\": \"http://127.0.0.1:60000/api/v0\",\n" +
|
||||||
" \"postbackBaseUrl\": \"http://127.0.0.1\",\n" +
|
" \"postbackBaseUrl\": \"http://127.0.0.1\",\n" +
|
||||||
|
@ -62,6 +66,8 @@ public class ConfigTest {
|
||||||
public void asSanitised() throws Exception {
|
public void asSanitised() throws Exception {
|
||||||
Reader reader = new StringReader("{\n" +
|
Reader reader = new StringReader("{\n" +
|
||||||
" \"port\": 80,\n" +
|
" \"port\": 80,\n" +
|
||||||
|
" \"bindIp\": \"127.0.0.1\",\n" +
|
||||||
|
" \"idleTimeout\": 30000,\n" +
|
||||||
" \"rootGitDirectory\": \"/var/wlgb/git\",\n" +
|
" \"rootGitDirectory\": \"/var/wlgb/git\",\n" +
|
||||||
" \"apiBaseUrl\": \"http://127.0.0.1:60000/api/v0\",\n" +
|
" \"apiBaseUrl\": \"http://127.0.0.1:60000/api/v0\",\n" +
|
||||||
" \"postbackBaseUrl\": \"http://127.0.0.1\",\n" +
|
" \"postbackBaseUrl\": \"http://127.0.0.1\",\n" +
|
||||||
|
@ -75,6 +81,8 @@ public class ConfigTest {
|
||||||
Config config = new Config(reader);
|
Config config = new Config(reader);
|
||||||
String expected = "{\n" +
|
String expected = "{\n" +
|
||||||
" \"port\": 80,\n" +
|
" \"port\": 80,\n" +
|
||||||
|
" \"bindIp\": \"127.0.0.1\",\n" +
|
||||||
|
" \"idleTimeout\": 30000,\n" +
|
||||||
" \"rootGitDirectory\": \"/var/wlgb/git\",\n" +
|
" \"rootGitDirectory\": \"/var/wlgb/git\",\n" +
|
||||||
" \"apiBaseURL\": \"http://127.0.0.1:60000/api/v0/\",\n" +
|
" \"apiBaseURL\": \"http://127.0.0.1:60000/api/v0/\",\n" +
|
||||||
" \"postbackURL\": \"http://127.0.0.1/\",\n" +
|
" \"postbackURL\": \"http://127.0.0.1/\",\n" +
|
||||||
|
|
|
@ -53,6 +53,8 @@ public class BridgeTest {
|
||||||
gcJob = mock(GcJob.class);
|
gcJob = mock(GcJob.class);
|
||||||
bridge = new Bridge(
|
bridge = new Bridge(
|
||||||
new Config(
|
new Config(
|
||||||
|
0,
|
||||||
|
"",
|
||||||
0,
|
0,
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
|
|
Loading…
Reference in a new issue