}\r
\r
// schedule lucene engine\r
- boolean luceneIndexing = settings.getBoolean(Keys.web.allowLuceneIndexing, true);\r
- logger.info("Lucene indexing is " + (luceneIndexing ? "" : "not") + " activated");\r
- \r
- if (luceneIndexing) {\r
- scheduledExecutor.scheduleAtFixedRate(luceneExecutor, 1, 2, TimeUnit.MINUTES);\r
- logger.info("Lucene executor is scheduled to process indexed branches every 2 minutes."); \r
- }\r
+ enableLuceneIndexing();\r
\r
\r
// schedule gc engine\r
}\r
}\r
\r
+ protected void enableLuceneIndexing() {\r
+ scheduledExecutor.scheduleAtFixedRate(luceneExecutor, 1, 2, TimeUnit.MINUTES);\r
+ logger.info("Lucene executor is scheduled to process indexed branches every 2 minutes.");\r
+ }\r
+ \r
+ protected final Logger getLogger() {\r
+ return logger;\r
+ }\r
+ \r
+ protected final ScheduledExecutorService getScheduledExecutor() {\r
+ return scheduledExecutor;\r
+ }\r
+\r
+ protected final LuceneExecutor getLuceneExecutor() {\r
+ return luceneExecutor;\r
+ }\r
+ \r
private void logTimezone(String type, TimeZone zone) {\r
SimpleDateFormat df = new SimpleDateFormat("z Z");\r
df.setTimeZone(zone);\r
private static Logger logger;\r
\r
public static void main(String... args) {\r
+ GitBlitServer server = new GitBlitServer();\r
+ \r
// filter out the baseFolder parameter\r
List<String> filtered = new ArrayList<String>();\r
String folder = "data";\r
try {\r
jc.parse(filtered.toArray(new String[filtered.size()]));\r
if (params.help) {\r
- usage(jc, null);\r
+ server.usage(jc, null);\r
}\r
} catch (ParameterException t) {\r
- usage(jc, t);\r
+ server.usage(jc, t);\r
}\r
\r
if (params.stop) {\r
- stop(params);\r
+ server.stop(params);\r
} else {\r
- start(params);\r
+ server.start(params);\r
}\r
}\r
\r
* @param jc\r
* @param t\r
*/\r
- private static void usage(JCommander jc, ParameterException t) {\r
+ protected final void usage(JCommander jc, ParameterException t) {\r
System.out.println(Constants.BORDER);\r
System.out.println(Constants.getGitBlitVersion());\r
System.out.println(Constants.BORDER);\r
/**\r
* Stop Gitblt GO.\r
*/\r
- public static void stop(Params params) {\r
+ public void stop(Params params) {\r
try {\r
Socket s = new Socket(InetAddress.getByName("127.0.0.1"), params.shutdownPort);\r
OutputStream out = s.getOutputStream();\r
/**\r
* Start Gitblit GO.\r
*/\r
- private static void start(Params params) {\r
+ protected final void start(Params params) {\r
final File baseFolder = new File(Params.baseFolder).getAbsoluteFile();\r
FileSettings settings = params.FILESETTINGS;\r
if (!StringUtils.isEmpty(params.settingsfile)) {\r
server.setHandler(rootContext);\r
\r
// Setup the GitBlit context\r
- GitBlit gitblit = GitBlit.self();\r
+ GitBlit gitblit = getGitBlitInstance();\r
gitblit.configureContext(settings, baseFolder, true);\r
rootContext.addEventListener(gitblit);\r
\r
System.exit(100);\r
}\r
}\r
+ \r
+ protected GitBlit getGitBlitInstance() {\r
+ return GitBlit.self();\r
+ }\r
\r
/**\r
* Creates an http connector.\r
* @param port\r
* @return an http connector\r
*/\r
- private static Connector createConnector(boolean useNIO, int port) {\r
+ private Connector createConnector(boolean useNIO, int port) {\r
Connector connector;\r
if (useNIO) {\r
logger.info("Setting up NIO SelectChannelConnector on port " + port);\r
* @param requireClientCertificates\r
* @return an https connector\r
*/\r
- private static Connector createSSLConnector(String certAlias, File keyStore, File clientTrustStore,\r
+ private Connector createSSLConnector(String certAlias, File keyStore, File clientTrustStore,\r
String storePassword, File caRevocationList, boolean useNIO, int port, \r
boolean requireClientCertificates) {\r
GitblitSslContextFactory factory = new GitblitSslContextFactory(certAlias,\r
* @param port\r
* @return an ajp connector\r
*/\r
- private static Connector createAJPConnector(int port) {\r
+ private Connector createAJPConnector(int port) {\r
logger.info("Setting up AJP Connector on port " + port);\r
Ajp13SocketConnector ajp = new Ajp13SocketConnector();\r
ajp.setPort(port);\r
* \r
* @return true if this is a windows machine\r
*/\r
- private static boolean isWindows() {\r
+ private boolean isWindows() {\r
return System.getProperty("os.name").toLowerCase().indexOf("windows") > -1;\r
}\r
\r
* JCommander Parameters class for GitBlitServer.\r
*/\r
@Parameters(separators = " ")\r
- private static class Params {\r
+ public static class Params {\r
\r
public static String baseFolder;\r
\r
--- /dev/null
+package de.akquinet.devops;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.beust.jcommander.JCommander;
+import com.beust.jcommander.ParameterException;
+import com.gitblit.GitBlit;
+import com.gitblit.GitBlitServer;
+
+public class GitBlitServer4UITests extends GitBlitServer {
+
+ public static void main(String... args) {
+ GitBlitServer4UITests server = new GitBlitServer4UITests();
+
+ // filter out the baseFolder parameter
+ List<String> filtered = new ArrayList<String>();
+ String folder = "data";
+ for (int i = 0; i < args.length; i++) {
+ String arg = args[i];
+ if (arg.equals("--baseFolder")) {
+ if (i + 1 == args.length) {
+ System.out.println("Invalid --baseFolder parameter!");
+ System.exit(-1);
+ } else if (args[i + 1] != ".") {
+ folder = args[i + 1];
+ }
+ i = i + 1;
+ } else {
+ filtered.add(arg);
+ }
+ }
+
+ Params.baseFolder = folder;
+ Params params = new Params();
+ JCommander jc = new JCommander(params);
+ try {
+ jc.parse(filtered.toArray(new String[filtered.size()]));
+ if (params.help) {
+ server.usage(jc, null);
+ }
+ } catch (ParameterException t) {
+ server.usage(jc, t);
+ }
+
+ if (params.stop) {
+ server.stop(params);
+ } else {
+ server.start(params);
+ }
+ }
+
+ private GitBlit4UITests instance;
+
+ @Override
+ protected GitBlit getGitBlitInstance() {
+ if (instance == null) {
+ instance = new GitBlit4UITests(false);
+ }
+ return instance;
+ }
+}