From 94e12c168f5eec300fd23d0de25c7dc93a96c429 Mon Sep 17 00:00:00 2001 From: James Moger <james.moger@gitblit.com> Date: Mon, 03 Mar 2014 17:51:21 -0500 Subject: [PATCH] Eliminate Gravatar profile linking and improve api --- src/main/java/com/gitblit/GitBlitServer.java | 46 ++++++++++++++++++++++++++++++++++++++++------ 1 files changed, 40 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/gitblit/GitBlitServer.java b/src/main/java/com/gitblit/GitBlitServer.java index ecb1001..1e51577 100644 --- a/src/main/java/com/gitblit/GitBlitServer.java +++ b/src/main/java/com/gitblit/GitBlitServer.java @@ -20,6 +20,7 @@ import java.io.File; import java.io.FileWriter; import java.io.IOException; +import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.net.InetAddress; @@ -33,8 +34,10 @@ import java.util.ArrayList; import java.util.Date; import java.util.List; +import java.util.Properties; import java.util.Scanner; +import org.apache.log4j.PropertyConfigurator; import org.eclipse.jetty.ajp.Ajp13SocketConnector; import org.eclipse.jetty.security.ConstraintMapping; import org.eclipse.jetty.security.ConstraintSecurityHandler; @@ -61,6 +64,7 @@ import com.beust.jcommander.Parameters; import com.gitblit.authority.GitblitAuthority; import com.gitblit.authority.NewCertificateConfig; +import com.gitblit.servlet.GitblitContext; import com.gitblit.utils.StringUtils; import com.gitblit.utils.TimeUtils; import com.gitblit.utils.X509Utils; @@ -178,6 +182,34 @@ settings = new FileSettings(params.settingsfile); } } + + if (params.dailyLogFile) { + // Configure log4j for daily log file generation + InputStream is = null; + try { + is = getClass().getResourceAsStream("/log4j.properties"); + Properties loggingProperties = new Properties(); + loggingProperties.load(is); + + loggingProperties.put("log4j.appender.R.File", new File(baseFolder, "logs/gitblit.log").getAbsolutePath()); + loggingProperties.put("log4j.rootCategory", "INFO, R"); + + if (settings.getBoolean(Keys.web.debugMode, false)) { + loggingProperties.put("log4j.logger.com.gitblit", "DEBUG"); + } + + PropertyConfigurator.configure(loggingProperties); + } catch (Exception e) { + e.printStackTrace(); + } finally { + try { + is.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + logger = LoggerFactory.getLogger(GitBlitServer.class); logger.info(Constants.BORDER); logger.info(" _____ _ _ _ _ _ _"); @@ -340,7 +372,7 @@ HashSessionManager sessionManager = new HashSessionManager(); sessionManager.setHttpOnly(true); // Use secure cookies if only serving https - sessionManager.setSecureCookies(params.port <= 0 && params.securePort > 0); + sessionManager.setSecureRequestOnly(params.port <= 0 && params.securePort > 0); rootContext.getSessionHandler().setSessionManager(sessionManager); // Ensure there is a defined User Service @@ -409,9 +441,8 @@ rootContext.setHandler(sh); } - // Setup the GitBlit context - GitBlit gitblit = newGitblit(settings, baseFolder); - gitblit.configureContext(settings, baseFolder, true); + // Setup the Gitblit context + GitblitContext gitblit = newGitblit(settings, baseFolder); rootContext.addEventListener(gitblit); try { @@ -430,8 +461,8 @@ } } - protected GitBlit newGitblit(IStoredSettings settings, File baseFolder) { - return new GitBlit(settings, baseFolder); + protected GitblitContext newGitblit(IStoredSettings settings, File baseFolder) { + return new GitblitContext(settings, baseFolder); } /** @@ -614,6 +645,9 @@ @Parameter(names = { "--tempFolder" }, description = "Folder for server to extract built-in webapp") public String temp = FILESETTINGS.getString(Keys.server.tempFolder, "temp"); + @Parameter(names = { "--dailyLogFile" }, description = "Log to a rolling daily log file INSTEAD of stdout.") + public Boolean dailyLogFile = false; + /* * GIT Servlet Parameters */ -- Gitblit v1.9.1