<commit_before>package com.googlecode.goclipse.core.tools;

import melnorme.lang.ide.core.LangCore;
import melnorme.lang.ide.core.operations.StartEngineDaemonOperation;
import melnorme.utilbox.collections.ArrayList2;
import melnorme.utilbox.process.ExternalProcessNotifyingHelper;

import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;

import com.googlecode.goclipse.builder.GoToolManager;
import com.googlecode.goclipse.core.GoCore;
import com.googlecode.goclipse.tooling.gocode.GocodeCompletionOperation;

/**
 * Start up an instance of Gocode in server mode.
 */
public class GocodeServer {
	
	private IPath path;
	protected ExternalProcessNotifyingHelper gocodeProcess;
	
	public GocodeServer(IPath gocodePath) {
		this.path = gocodePath;
	}
	
	public void startServer() {
		
		GoCore.logInfo("starting gocode server [" + path + "]");
		
		ArrayList2<String> commandLine = new ArrayList2<String>();
		commandLine.add(path.toOSString());
		
		commandLine.add("-s");
		
		if (GocodeCompletionOperation.USE_TCP) {
			commandLine.add("-sock=tcp");
		}
		
		ProcessBuilder pb = new ProcessBuilder(commandLine);
		
		try {
			new StartEngineDaemonOperation(GoToolManager.getDefault(), pb).call();
		} catch (CoreException ce) {
			LangCore.logStatus(ce.getStatus());<commit_msg>Fix #54 - gocode server not being killed.<commit_after>package com.googlecode.goclipse.core.tools;

import melnorme.lang.ide.core.LangCore;
import melnorme.lang.ide.core.operations.StartEngineDaemonOperation;
import melnorme.lang.ide.core.utils.process.EclipseExternalProcessHelper;
import melnorme.utilbox.collections.ArrayList2;
import melnorme.utilbox.process.ExternalProcessNotifyingHelper;

import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;

import com.googlecode.goclipse.builder.GoToolManager;
import com.googlecode.goclipse.core.GoCore;
import com.googlecode.goclipse.tooling.gocode.GocodeCompletionOperation;

/**
 * Start up an instance of Gocode in server mode.
 */
public class GocodeServer {
	
	private IPath path;
	protected ExternalProcessNotifyingHelper gocodeProcess;
	
	public GocodeServer(IPath gocodePath) {
		this.path = gocodePath;
	}
	
	public void startServer() {
		
		GoCore.logInfo("starting gocode server [" + path + "]");
		
		ArrayList2<String> commandLine = new ArrayList2<String>();
		commandLine.add(path.toOSString());
		
		commandLine.add("-s");
		
		if (GocodeCompletionOperation.USE_TCP) {
			commandLine.add("-sock=tcp");
		}
		
		ProcessBuilder pb = new ProcessBuilder(commandLine);
		
		try {
			EclipseExternalProcessHelper eph = new StartEngineDaemonOperation(GoToolManager.getDefault(), pb).call();
			gocodeProcess = eph.getNotifyingProcessHelper();
		} catch (CoreException ce) {
			LangCore.logStatus(ce.getStatus());
{'fraction_non_alphanumeric': 0.10972568578553615, 'fraction_numerical': 0.0028500178126113287, 'mean_word_length': 5.2959641255605385, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '4443227', 'n_tokens_mistral': 972, 'n_tokens_neox': 886, 'n_words': 153}