mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-01 02:56:08 +01:00
(refs #96)Add --port and --prefix option.
This commit is contained in:
@@ -6,13 +6,28 @@ import java.security.ProtectionDomain;
|
||||
|
||||
public class JettyLauncher {
|
||||
public static void main(String[] args) throws Exception {
|
||||
int port = System.getenv("PORT") != null ? Integer.parseInt(System.getenv("PORT")) : 8080;
|
||||
int port = 8080;
|
||||
String contextPath = "/";
|
||||
|
||||
for(String arg: args){
|
||||
if(arg.startsWith("--") && arg.contains("=")){
|
||||
String[] dim = arg.split("=");
|
||||
if(dim.length >= 2){
|
||||
if(dim[0].equals("--port")){
|
||||
port = Integer.parseInt(dim[1]);
|
||||
} else if(dim[0].equals("--prefix")){
|
||||
contextPath = dim[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Server server = new Server(port);
|
||||
WebAppContext context = new WebAppContext();
|
||||
ProtectionDomain domain = JettyLauncher.class.getProtectionDomain();
|
||||
URL location = domain.getCodeSource().getLocation();
|
||||
|
||||
context.setContextPath("/");
|
||||
context.setContextPath(contextPath);
|
||||
context.setDescriptor(location.toExternalForm() + "/WEB-INF/web.xml");
|
||||
context.setServer(server);
|
||||
context.setWar(location.toExternalForm());
|
||||
|
||||
Reference in New Issue
Block a user