Merge pull request #1432 from dariko/add_temp_dir_parameter

add temp_dir option
This commit is contained in:
Naoki Takezoe
2017-01-24 14:01:46 +09:00
committed by GitHub
2 changed files with 26 additions and 3 deletions

View File

@@ -32,6 +32,14 @@ You can specify following options:
- `--prefix=[CONTEXTPATH]`
- `--host=[HOSTNAME]`
- `--gitbucket.home=[DATA_DIR]`
- `--temp_dir=[TEMP_DIR]`
`TEMP_DIR` is used as the [temporary directory for the jetty application context](https://www.eclipse.org/jetty/documentation/9.3.x/ref-temporary-directories.html).
This is the directory into which the gitbucket.war file is unpacked, the source
files are compiled, etc.
If given this parameter **must** match the path of an existing directory
or the application will quit reporting an error; if not given the path used
will be a `tmp` directory inside the gitbucket home.
You can also deploy gitbucket.war to a servlet container which supports Servlet 3.0 (like Jetty, Tomcat, JBoss, etc)

View File

@@ -12,6 +12,7 @@ public class JettyLauncher {
int port = 8080;
InetSocketAddress address = null;
String contextPath = "/";
String tmpDirPath="";
boolean forceHttps = false;
for(String arg: args) {
@@ -29,6 +30,8 @@ public class JettyLauncher {
}
} else if(dim[0].equals("--gitbucket.home")){
System.setProperty("gitbucket.home", dim[1]);
} else if(dim[0].equals("--temp_dir")){
tmpDirPath = dim[1];
}
}
}
@@ -53,9 +56,21 @@ public class JettyLauncher {
WebAppContext context = new WebAppContext();
File tmpDir = new File(getGitBucketHome(), "tmp");
if(!tmpDir.exists()){
tmpDir.mkdirs();
File tmpDir;
if(tmpDirPath.equals("")){
tmpDir = new File(getGitBucketHome(), "tmp");
if(!tmpDir.exists()){
tmpDir.mkdirs();
}
} else {
tmpDir = new File(tmpDirPath);
if(!tmpDir.exists()){
throw new java.io.FileNotFoundException(
String.format("temp_dir \"%s\" not found", tmpDirPath));
} else if(!tmpDir.isDirectory()) {
throw new IllegalArgumentException(
String.format("temp_dir \"%s\" is not a directory", tmpDirPath));
}
}
context.setTempDirectory(tmpDir);