<commit_before>package com.amebame.triton.server;

import java.net.InetSocketAddress;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.jboss.netty.bootstrap.ServerBootstrap;
import org.jboss.netty.channel.ChannelPipelineFactory;

import com.beust.jcommander.JCommander;
import com.beust.jcommander.Parameter;
import com.google.inject.Guice;
import com.google.inject.Injector;

public class TritonServer {
	
	private static final Logger log = LogManager.getLogger(TritonServer.class);
	
	@Parameter(names = {"-p","--port"}, description="server port")
	private int port = 4848;
	
	@Parameter(names = {"-c","--config"}, description="config path")
	private String configPath = null;
	
	@Parameter(names = {"-h","--help"}, description="print this help")
	private boolean help = false;
	
	// Guice injector
	private Injector injector;
	
	public TritonServer() {
	}
	
	public void setPort(int port) {
		this.port = port;
	}
	
	public void setConfigPath(String configPath) {
		this.configPath = configPath;
	}
	
	public void start() {
		log.info("starting triton server");
		try {
			injector = Guice.createInjector(new TritonModule(configPath));
			ServerBootstrap bootstrap = injector.getInstance(ServerBootstrap.class);
			ChannelPipelineFactory pipelineFactory = injector.getInstance(TritonServerPipelineFactory.class);
			bootstrap.setPipelineFactory(pipelineFactory);
			bootstrap.bind(new InetSocketAddress(port));
			log.info("triton server started on port {}", port);
		} catch (Exception e) {
			log.error("failed to start the server {}", e.getMessage(), e);
		}
	}
	
	public void stop() {
		log.info("stopping triton server");
		if (injector == null) {
			return;
		}
		ServerBootstrap bootstrap = injector.getInstance(ServerBootstrap.class);
		if (bootstrap != null) {
			bootstrap.shutdown();<commit_msg>Enable tcpNoDelay and keepAlive.<commit_after>package com.amebame.triton.server;

import java.net.InetSocketAddress;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.jboss.netty.bootstrap.ServerBootstrap;
import org.jboss.netty.channel.ChannelPipelineFactory;

import com.beust.jcommander.JCommander;
import com.beust.jcommander.Parameter;
import com.google.inject.Guice;
import com.google.inject.Injector;

public class TritonServer {
	
	private static final Logger log = LogManager.getLogger(TritonServer.class);
	
	@Parameter(names = {"-p","--port"}, description="server port")
	private int port = 4848;
	
	@Parameter(names = {"-c","--config"}, description="config path")
	private String configPath = null;
	
	@Parameter(names = {"-h","--help"}, description="print this help")
	private boolean help = false;
	
	// Guice injector
	private Injector injector;
	
	public TritonServer() {
	}
	
	public void setPort(int port) {
		this.port = port;
	}
	
	public void setConfigPath(String configPath) {
		this.configPath = configPath;
	}
	
	public void start() {
		log.info("starting triton server");
		try {
			injector = Guice.createInjector(new TritonModule(configPath));
			ServerBootstrap bootstrap = injector.getInstance(ServerBootstrap.class);
			ChannelPipelineFactory pipelineFactory = injector.getInstance(TritonServerPipelineFactory.class);
			bootstrap.setPipelineFactory(pipelineFactory);
			bootstrap.setOption("child.tcpNoDelay", true);
			bootstrap.setOption("child.keepAlive", true);
			bootstrap.bind(new InetSocketAddress(port));
			log.info("triton server started on port {}", port);
		} catch (Exception e) {
			log.error("failed to start the server {}", e.getMessage(), e);
		}
	}
	
	public void stop() {
		log.info("stopping triton server");
		if (injector == null) {
			return;
		}
		ServerBootstrap bootstrap = injector.getInstance(ServerBootstrap.class);
		if (bootstrap != null) {
			bootstrap.shutdown();
{'fraction_non_alphanumeric': 0.12558746736292428, 'fraction_numerical': 0.003133159268929504, 'mean_word_length': 4.93953488372093, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3747312', 'n_tokens_mistral': 1286, 'n_tokens_neox': 1155, 'n_words': 256}