Skip to content

Commit

Permalink
add temp_dir parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
dariko committed Jan 22, 2017
1 parent 6bb664e commit 9727259
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ You can specify following options:
- `--prefix=[CONTEXTPATH]`
- `--host=[HOSTNAME]`
- `--gitbucket.home=[DATA_DIR]`
- `--temp_dir=[TEMP_DIR]`

You can also deploy gitbucket.war to a servlet container which supports Servlet 3.0 (like Jetty, Tomcat, JBoss, etc)

Expand Down
21 changes: 18 additions & 3 deletions src/main/java/JettyLauncher.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public static void main(String[] args) throws Exception {
int port = 8080;
InetSocketAddress address = null;
String contextPath = "/";
String tmpDirPath="";
boolean forceHttps = false;

for(String arg: args) {
Expand All @@ -29,6 +30,8 @@ public static void main(String[] args) throws Exception {
}
} else if(dim[0].equals("--gitbucket.home")){
System.setProperty("gitbucket.home", dim[1]);
} else if(dim[0].equals("--temp_dir")){
tmpDirPath = dim[1];
}
}
}
Expand All @@ -53,9 +56,21 @@ public static void main(String[] args) throws Exception {

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);

Expand Down

0 comments on commit 9727259

Please sign in to comment.