<commit_before>package main

import (
	"encoding/json"
	"fmt"
	"net"
	"net/http"
	"os"
	"os/signal"
	"syscall"

	"github.com/gorilla/mux"
)

func main() {
	fmt.Printf("blocker: starting up...\n")

	d, err := NewEbsVolumeDriver()
	if err != nil {
		fmt.Printf("error: %s\n", err)
		return
	}

	// Done is a channel that signals program exit.
	done := make(chan bool, 1)

	// Listen to important OS signals, so we trigger exit cleanly.
	signals := make(chan os.Signal, 1)
	signal.Notify(signals, os.Interrupt, os.Kill, syscall.SIGTERM)
	go func() {
		sig := <-signals
		fmt.Printf("Caught signal %s: shutting down.\n", sig)
		// TODO: forcibly unmount all volumes.
		done <- true
	}()

	// Now listen for HTTP calls from Docker.
	go listen(d, true, done)

	// Block until the program exits.
	<-done
}

func listen(d VolumeDriver, socket bool, done chan bool) {
	handler := makeRoutes(d)

	if socket {
		const SocketFile = "/var/run/blocker/blocker.sock"

		l, err := net.Listen("unix", SocketFile)
		if err != nil {
			fmt.Printf("Error listening on socket %s: %s.\n", SocketFile, err)
			return
		}
		defer l.Close()

		fmt.Printf("Ready to go; listening on socket %s...\n", SocketFile)
		err = http.Serve(l, handler)
		if err != nil {
			fmt.Printf("HTTP server error: %s.\n", err)
		}
	} else {
		const ListenAddress = ":1234"

		fmt.Printf("Ready to go; listening on port %s...\n", ListenAddress)
		err := http.ListenAndServe(ListenAddress, handler)
		if err != nil {
			fmt.Printf("HTTP server error: %s.\n", err)
		}
	}<commit_msg>Fix socket bind error handling logic<commit_after>package main

import (
	"encoding/json"
	"fmt"
	"net"
	"net/http"
	"os"
	"os/signal"
	"syscall"

	"github.com/gorilla/mux"
)

func main() {
	fmt.Printf("blocker: starting up...\n")

	d, err := NewEbsVolumeDriver()
	if err != nil {
		fmt.Printf("error: %s\n", err)
		return
	}

	// Done is a channel that signals program exit.
	done := make(chan bool, 1)

	// Listen to important OS signals, so we trigger exit cleanly.
	signals := make(chan os.Signal, 1)
	signal.Notify(signals, os.Interrupt, os.Kill, syscall.SIGTERM)
	go func() {
		sig := <-signals
		fmt.Printf("Caught signal %s: shutting down.\n", sig)
		// TODO: forcibly unmount all volumes.
		done <- true
	}()

	// Now listen for HTTP calls from Docker.
	go listen(d, true, done)

	// Block until the program exits.
	<-done
}

func listen(d VolumeDriver, socket bool, done chan bool) {
	handler := makeRoutes(d)

	if socket {
		const SocketFile = "/var/run/blocker/blocker.sock"

		l, err := net.Listen("unix", SocketFile)
		if err != nil {
			fmt.Printf("Error listening on socket %s: %s.\n", SocketFile, err)
		} else {
			defer l.Close()

			fmt.Printf("Ready to go; listening on socket %s...\n", SocketFile)
			err = http.Serve(l, handler)
			if err != nil {
				fmt.Printf("HTTP server error: %s.\n", err)
			}
		}
	} else {
		const ListenAddress = ":1234"

		fmt.Printf("Ready to go; listening on port %s...\n", ListenAddress)
		err := http.ListenAndServe(ListenAddress, handler)
		if err != nil {
			fmt.Printf("HTTP server error: %s.\n", err)
		}
	}
{'fraction_non_alphanumeric': 0.15548387096774194, 'fraction_numerical': 0.003870967741935484, 'mean_word_length': 3.2075983717774763, 'pattern_counts': {'":': 2, '<': 9, '<?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': '5230353', 'n_tokens_mistral': 1237, 'n_tokens_neox': 1124, 'n_words': 335}