<commit_before>package main

import (
	"net"
	"os/exec"
	"time"
)

func SshRunning() bool {
	c, err := net.Dial("tcp", config.socksAddr)
	if err != nil {
		return false
	}
	c.Close()
	return true
}

func runSSH() {
	if config.sshServer == "" {
		return
	}

	_, port := splitHostPort(config.socksAddr)
	alreadyRunPrinted := false

	for {
		if SshRunning() {
			if !alreadyRunPrinted {
				errl.Println("ssh socks server maybe already running, as cow can connect to",
					config.socksAddr)
				alreadyRunPrinted = true
			}
			// check server liveness in 1 minute
			time.Sleep(60 * time.Second)
			continue
		}

		// -n redirects stdin from /dev/null
		// -N do not execute remote command
		cmd := exec.Command("ssh", "-n", "-N", "-D", port, config.sshServer)
		if err := cmd.Run(); err != nil {
			errl.Println("ssh:", err)
		}
		info.Println("ssh exited, reconnect")
		time.Sleep(5 * time.Second)
		alreadyRunPrinted = false
	}
}<commit_msg>Use debug output for ssh error message.<commit_after>package main

import (
	"net"
	"os/exec"
	"time"
)

func SshRunning() bool {
	c, err := net.Dial("tcp", config.socksAddr)
	if err != nil {
		return false
	}
	c.Close()
	return true
}

func runSSH() {
	if config.sshServer == "" {
		return
	}

	_, port := splitHostPort(config.socksAddr)
	alreadyRunPrinted := false

	for {
		if SshRunning() {
			if !alreadyRunPrinted {
				errl.Println("ssh socks server maybe already running, as cow can connect to",
					config.socksAddr)
				alreadyRunPrinted = true
			}
			// check server liveness in 1 minute
			time.Sleep(60 * time.Second)
			continue
		}

		// -n redirects stdin from /dev/null
		// -N do not execute remote command
		cmd := exec.Command("ssh", "-n", "-N", "-D", port, config.sshServer)
		if err := cmd.Run(); err != nil {
			debug.Println("ssh:", err)
		}
		info.Println("ssh exited, reconnect")
		time.Sleep(5 * time.Second)
		alreadyRunPrinted = false
	}
}
{'fraction_non_alphanumeric': 0.1427077888133821, 'fraction_numerical': 0.004181913225300575, 'mean_word_length': 3.107296137339056, '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': '5534502', 'n_tokens_mistral': 789, 'n_tokens_neox': 682, 'n_words': 186}