<commit_before>package yami;

import javax.servlet.http.HttpServlet;

import org.apache.log4j.BasicConfigurator;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.apache.log4j.PatternLayout;
import org.apache.log4j.RollingFileAppender;
import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.handler.ContextHandler;
import org.eclipse.jetty.server.handler.ContextHandlerCollection;
import org.eclipse.jetty.server.handler.ResourceHandler;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder;

import yami.model.Constants;

public class YamiServerBootstrap
{
	private final Logger log = Logger.getLogger(YamiServerBootstrap.class);
	
	public static void main(String[] args)
	{
		setLogger(Constants.getInstallDir() + "/http-root/" + Constants.SERVER_LOG);
		configureLogLevel();
		new YamiServerBootstrap().runServer();
	}
	
	private void runServer()
	{
		String installDir = Constants.getInstallDir();
		log.info("Starting yami server at version " + YamiVersion.get());
		int port = Constants.getServerPort();
		log.info("starting with port " + port);
		log.info("to set different server port, use -DserverPort=<port>");
		log.info("starting static server under '/', serving" + installDir + "/http-root");
		ContextHandler staticResouceContextHandler = createStaticContextHandler("/", installDir + "/http-root");
		log.info("starting dashboard servlet under '/dashboard'");
		ServletContextHandler dashboardContext = createServletContext("/dashboard", new DashboardServlet());
		ContextHandlerCollection contexts = new ContextHandlerCollection();
		contexts.setHandlers(new Handler[] { staticResouceContextHandler, dashboardContext });
		Server server = new Server(port);
		server.setHandler(contexts);
		try
		{
			new Thread(new UpdaterThread()).start();
			server.start();
		}
		catch (Exception e)
		{
			log.error("got an exception at server main ", e);
			e.printStackTrace();
		}
	}
	
	private static void setLogger(String logfile) throws RuntimeException
	{
		System.out.println("flag to stdout: " + System.getProperty("log.to.stdout"));
		if (Boolean.getBoolean("log.to.stdout"))
		{
			BasicConfigurator.configure();
			Logger.getRootLogger().setLevel(Level.INFO);
			return;
		}
		String pattern = "%d{ISO8601} [%c] %p %m %n";<commit_msg>minor change, testing git<commit_after>package yami;

import javax.servlet.http.HttpServlet;

import org.apache.log4j.BasicConfigurator;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.apache.log4j.PatternLayout;
import org.apache.log4j.RollingFileAppender;
import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.handler.ContextHandler;
import org.eclipse.jetty.server.handler.ContextHandlerCollection;
import org.eclipse.jetty.server.handler.ResourceHandler;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder;

import yami.model.Constants;

public class YamiServerBootstrap
{
	private final Logger log = Logger.getLogger(YamiServerBootstrap.class);
	
	public static void main(String[] args)
	{
		setLogger(Constants.getInstallDir() + "/http-root/" + Constants.SERVER_LOG);
		configureLogLevel();
		new YamiServerBootstrap().runServer();
	}
	
	private void runServer()
	{
		String installDir = Constants.getInstallDir();
		log.info("Starting yami server at version " + YamiVersion.get());
		int port = Constants.getServerPort();
		log.info("Starting on port "+ port + ". To set different server port, use -DserverPort=<port>");
		log.info("starting static server under '/', serving" + installDir + "/http-root");
		ContextHandler staticResouceContextHandler = createStaticContextHandler("/", installDir + "/http-root");
		log.info("starting dashboard servlet under '/dashboard'");
		ServletContextHandler dashboardContext = createServletContext("/dashboard", new DashboardServlet());
		ContextHandlerCollection contexts = new ContextHandlerCollection();
		contexts.setHandlers(new Handler[] { staticResouceContextHandler, dashboardContext });
		Server server = new Server(port);
		server.setHandler(contexts);
		try
		{
			new Thread(new UpdaterThread()).start();
			server.start();
		}
		catch (Exception e)
		{
			log.error("got an exception at server main ", e);
			e.printStackTrace();
		}
	}
	
	private static void setLogger(String logfile) throws RuntimeException
	{
		System.out.println("flag to stdout: " + System.getProperty("log.to.stdout"));
		if (Boolean.getBoolean("log.to.stdout"))
		{
			BasicConfigurator.configure();
			Logger.getRootLogger().setLevel(Level.INFO);
			return;
		}
		String pattern = "%d{ISO8601} [%c] %p %m %n";
{'fraction_non_alphanumeric': 0.126207475850483, 'fraction_numerical': 0.0037799244015119695, 'mean_word_length': 5.393288590604027, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7474263', 'n_tokens_mistral': 1521, 'n_tokens_neox': 1414, 'n_words': 300}