<commit_before>// server.go

package server

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"os/exec"
)

const (
	ClientPort string = ":4000"
	PeerPort   string = ":4004"
)

type EtcdAdapter struct {
	peer_addresses   []string
	client_addresses []string // for clients
	processes        []*os.Process
	launchProcess    chan *os.Process
	killAll          chan bool
}

func (c *EtcdAdapter) Addresses() []string {
	return c.client_addresses
}

func check(e error) {
	if e != nil {
		panic(e)
	}
}

func (c *EtcdAdapter) ExecWithLog(cmd *exec.Cmd, i int) {
	stdoutPipe, err := cmd.StdoutPipe()
	check(err)
	stderrPipe, err := cmd.StderrPipe()
	check(err)

	out_file, err := os.Create(fmt.Sprintf("log/etcd_%d.out", i))
	check(err)
	err_file, err := os.Create(fmt.Sprintf("log/etcd_%d.err", i))
	check(err)

	out_writer := bufio.NewWriter(out_file)
	err_writer := bufio.NewWriter(err_file)

	defer out_writer.Flush()
	defer err_writer.Flush()

	// Start the command
	err = cmd.Start()
	check(err)

	go io.Copy(out_writer, stdoutPipe)
	go io.Copy(err_writer, stderrPipe)

	c.launchProcess <- cmd.Process

	cmd.Wait()
}

func (c *EtcdAdapter) nameFromPeer(peer string) string {
	for i, address := range c.peer_addresses {
		if peer == address {
			return name(i)
		}
	}
	panic(fmt.Sprintf("No such peer: %s", peer))<commit_msg>Writing logs to /tmp<commit_after>// server.go

package server

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"os/exec"
)

const (
	ClientPort string = ":4000"
	PeerPort   string = ":4004"
)

type EtcdAdapter struct {
	peer_addresses   []string
	client_addresses []string // for clients
	processes        []*os.Process
	launchProcess    chan *os.Process
	killAll          chan bool
}

func (c *EtcdAdapter) Addresses() []string {
	return c.client_addresses
}

func check(e error) {
	if e != nil {
		panic(e)
	}
}

func (c *EtcdAdapter) ExecWithLog(cmd *exec.Cmd, i int) {
	stdoutPipe, err := cmd.StdoutPipe()
	check(err)
	stderrPipe, err := cmd.StderrPipe()
	check(err)

	out_file, err := os.Create(fmt.Sprintf("/tmp/etcd_%d.out", i))
	check(err)
	err_file, err := os.Create(fmt.Sprintf("/tmp/etcd_%d.err", i))
	check(err)

	out_writer := bufio.NewWriter(out_file)
	err_writer := bufio.NewWriter(err_file)

	defer out_writer.Flush()
	defer err_writer.Flush()

	// Start the command
	err = cmd.Start()
	check(err)

	go io.Copy(out_writer, stdoutPipe)
	go io.Copy(err_writer, stderrPipe)

	c.launchProcess <- cmd.Process

	cmd.Wait()
}

func (c *EtcdAdapter) nameFromPeer(peer string) string {
	for i, address := range c.peer_addresses {
		if peer == address {
			return name(i)
		}
	}
	panic(fmt.Sprintf("No such peer: %s", peer))
{'fraction_non_alphanumeric': 0.14546145081655906, 'fraction_numerical': 0.0060767185719711354, 'mean_word_length': 3.83302752293578, 'pattern_counts': {'":': 4, '<': 5, '<?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': '337398', 'n_tokens_mistral': 1086, 'n_tokens_neox': 1032, 'n_words': 236}