<commit_before>package main

import (
	"github.com/dotcloud/beam"
	"os/exec"
	"log"
	"fmt"
)

func main() {
	if err := RunServer(); err != nil {
		log.Fatal(err)
	}
}

func RunServer() error {
	srv := beam.NewServer()
	srv.RegisterJob("hello", JobHelloWorld)
	srv.RegisterJob("exec", JobExec)
	if err := srv.ListenAndServe("unix", "./beam.sock"); err != nil {
		return err
	}
	return nil
}


func JobHello(name string, args []string, env map[string]string, db beam.DB, streams beam.Streamer) error {
	 // FIXME: can we get away with not returning errors? Maybe the server just kills the handler on error?
	stdout := streams.Open("stdout", beam.O_WRONLY)
	fmt.Fprintf(stdout, "Hello, %s!", strings.Join(args, " "))
	return nil
}

func JobExec(name string, args []string, env map[string]string, db beam.DB, streams beam.Streamer) error {
	var (
		cmdName string
		cmdArgs []string
	)
	if len(args) >= 1 {
		cmdName = args[0]
	} else {
		return fmt.Errorf("Not enough arguments")
	}
	if len(args) > 1 {
		cmdArgs = args[1:]
	}
	p := exec.Command(cmdName, cmdArgs...)<commit_msg>Move db to last argument of job handlers, to group unix-style arguments together.<commit_after>package main

import (
	"github.com/dotcloud/beam"
	"os/exec"
	"log"
	"fmt"
)

func main() {
	if err := RunServer(); err != nil {
		log.Fatal(err)
	}
}

func RunServer() error {
	srv := beam.NewServer()
	srv.RegisterJob("hello", JobHelloWorld)
	srv.RegisterJob("exec", JobExec)
	if err := srv.ListenAndServe("unix", "./beam.sock"); err != nil {
		return err
	}
	return nil
}


func JobHello(name string, args []string, env map[string]string, streams beam.Streamer, db beam.DB) error {
	 // FIXME: can we get away with not returning errors? Maybe the server just kills the handler on error?
	stdout := streams.Open("stdout", beam.O_WRONLY)
	fmt.Fprintf(stdout, "Hello, %s!", strings.Join(args, " "))
	return nil
}

func JobExec(name string, args []string, env map[string]string, streams beam.Streamer, db beam.DB) error {
	var (
		cmdName string
		cmdArgs []string
	)
	if len(args) >= 1 {
		cmdName = args[0]
	} else {
		return fmt.Errorf("Not enough arguments")
	}
	if len(args) > 1 {
		cmdArgs = args[1:]
	}
	p := exec.Command(cmdName, cmdArgs...)
{'fraction_non_alphanumeric': 0.15193868349864742, 'fraction_numerical': 0.0036068530207394047, 'mean_word_length': 4.00902934537246, 'pattern_counts': {'":': 0, '<': 3, '<?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': '5494068', 'n_tokens_mistral': 824, 'n_tokens_neox': 794, 'n_words': 227}