mirror of
https://github.com/2006-Scape/apollo.git
synced 2026-07-06 00:38:18 +00:00
Merge pull request #73 from ryleykimmel/master
Update dependencies, do not fail startup when we cannot bind to HTTP (just use jaggrab as a fallback)
This commit is contained in:
@@ -1,12 +1,6 @@
|
|||||||
package org.apollo;
|
package org.apollo;
|
||||||
|
|
||||||
import io.netty.bootstrap.ServerBootstrap;
|
import java.net.BindException;
|
||||||
import io.netty.channel.ChannelInitializer;
|
|
||||||
import io.netty.channel.EventLoopGroup;
|
|
||||||
import io.netty.channel.nio.NioEventLoopGroup;
|
|
||||||
import io.netty.channel.socket.SocketChannel;
|
|
||||||
import io.netty.channel.socket.nio.NioServerSocketChannel;
|
|
||||||
|
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.net.SocketAddress;
|
import java.net.SocketAddress;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
@@ -28,6 +22,13 @@ import org.apollo.net.release.Release;
|
|||||||
|
|
||||||
import com.google.common.base.Stopwatch;
|
import com.google.common.base.Stopwatch;
|
||||||
|
|
||||||
|
import io.netty.bootstrap.ServerBootstrap;
|
||||||
|
import io.netty.channel.ChannelInitializer;
|
||||||
|
import io.netty.channel.EventLoopGroup;
|
||||||
|
import io.netty.channel.nio.NioEventLoopGroup;
|
||||||
|
import io.netty.channel.socket.SocketChannel;
|
||||||
|
import io.netty.channel.socket.nio.NioServerSocketChannel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The core class of the Apollo server.
|
* The core class of the Apollo server.
|
||||||
*
|
*
|
||||||
@@ -59,6 +60,7 @@ public final class Server {
|
|||||||
server.bind(service, http, jaggrab);
|
server.bind(service, http, jaggrab);
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
logger.log(Level.SEVERE, "Error whilst starting server.", t);
|
logger.log(Level.SEVERE, "Error whilst starting server.", t);
|
||||||
|
System.exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.fine("Starting apollo took " + stopwatch.elapsed(TimeUnit.MILLISECONDS) + " ms.");
|
logger.fine("Starting apollo took " + stopwatch.elapsed(TimeUnit.MILLISECONDS) + " ms.");
|
||||||
@@ -97,25 +99,42 @@ public final class Server {
|
|||||||
* @param service The service address to bind to.
|
* @param service The service address to bind to.
|
||||||
* @param http The HTTP address to bind to.
|
* @param http The HTTP address to bind to.
|
||||||
* @param jaggrab The JAGGRAB address to bind to.
|
* @param jaggrab The JAGGRAB address to bind to.
|
||||||
|
* @throws BindException If the ServerBootstrap fails to bind to the SocketAddress for any
|
||||||
|
* reason.
|
||||||
*/
|
*/
|
||||||
public void bind(SocketAddress service, SocketAddress http, SocketAddress jaggrab) {
|
public void bind(SocketAddress service, SocketAddress http, SocketAddress jaggrab) throws BindException {
|
||||||
|
logger.fine("Binding service listener to address: " + service + "...");
|
||||||
|
bind(serviceBootstrap, service);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
logger.fine("Binding service listener to address: " + service + "...");
|
logger.fine("Binding HTTP listener to address: " + http + "...");
|
||||||
serviceBootstrap.bind(service).sync();
|
bind(httpBootstrap, http);
|
||||||
|
} catch (Exception cause) {
|
||||||
logger.fine("Binding HTTP listener to address: " + http + "...");
|
logger.warning("Unable to bind to HTTP, JAGGRAB will be used as a fallback however this is not recommended.");
|
||||||
httpBootstrap.bind(http).sync();
|
|
||||||
|
|
||||||
logger.fine("Binding JAGGRAB listener to address: " + jaggrab + "...");
|
|
||||||
jaggrabBootstrap.bind(jaggrab).sync();
|
|
||||||
} catch (InterruptedException exception) {
|
|
||||||
logger.log(Level.SEVERE, "Binding to a port failed: ensure apollo isn't already running.", exception);
|
|
||||||
System.exit(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logger.fine("Binding JAGGRAB listener to address: " + jaggrab + "...");
|
||||||
|
bind(jaggrabBootstrap, jaggrab);
|
||||||
|
|
||||||
logger.info("Ready for connections.");
|
logger.info("Ready for connections.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attempts to bind the specified ServerBootstrap to the specified SocketAddress.
|
||||||
|
*
|
||||||
|
* @param bootstrap The ServerBootstrap.
|
||||||
|
* @param address The SocketAddress.
|
||||||
|
* @throws BindException If the ServerBootstrap fails to bind to the SocketAddress for any
|
||||||
|
* reason.
|
||||||
|
*/
|
||||||
|
private void bind(ServerBootstrap bootstrap, SocketAddress address) throws BindException {
|
||||||
|
try {
|
||||||
|
bootstrap.bind(address).sync();
|
||||||
|
} catch (Exception cause) {
|
||||||
|
throw new BindException("Failed to bind to: " + address);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialises the server.
|
* Initialises the server.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -47,13 +47,13 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.commons</groupId>
|
<groupId>org.apache.commons</groupId>
|
||||||
<artifactId>commons-compress</artifactId>
|
<artifactId>commons-compress</artifactId>
|
||||||
<version>1.9</version>
|
<version>1.10</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.jruby</groupId>
|
<groupId>org.jruby</groupId>
|
||||||
<artifactId>jruby-complete</artifactId>
|
<artifactId>jruby-complete</artifactId>
|
||||||
<version>1.7.19</version>
|
<version>9.0.0.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
@@ -65,7 +65,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.netty</groupId>
|
<groupId>io.netty</groupId>
|
||||||
<artifactId>netty-all</artifactId>
|
<artifactId>netty-all</artifactId>
|
||||||
<version>4.0.27.Final</version>
|
<version>4.0.30.Final</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
@@ -78,7 +78,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.mchange</groupId>
|
<groupId>com.mchange</groupId>
|
||||||
<artifactId>c3p0</artifactId>
|
<artifactId>c3p0</artifactId>
|
||||||
<version>0.9.5</version>
|
<version>0.9.5.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
Reference in New Issue
Block a user