<commit_before>package main

import (
    "os"
    "os/signal"
    "syscall"
    "log/syslog"
)

var g_logger, _ = syslog.NewLogger(syslog.LOG_NOTICE | syslog.LOG_CRON, 0)
var g_err_logger, _ = syslog.NewLogger(syslog.LOG_ERR | syslog.LOG_CRON, 0)

func stopServerOnSignal(server *IpcServer, jm *JobManager) {
    // Set up channel on which to send signal notifications.
	// We must use a buffered channel or risk missing the signal
	// if we're not ready to receive when the signal is sent.
	c := make(chan os.Signal, 1)
	signal.Notify(c, os.Interrupt, syscall.SIGTERM, os.Kill)

	// Block until a signal is received.
	<-c
	g_logger.Printf("Got signal.\n")
	server.Stop()
	jm.Cancel()
	jm.Wait()
	os.Exit(0)
}

func main() {
    var err error
    
    // run them
	manager, err := NewJobManager()
	if err != nil {
        g_err_logger.Printf("Error: %v\n", err)
        os.Exit(1)
    }
	cmdChan, err := manager.Launch()
	if err != nil {
        g_err_logger.Printf("Error: %v\n", err)
        os.Exit(1)
    }
    
    // make IPC server
    ipcServer := NewIpcServer(cmdChan)
    go stopServerOnSignal(ipcServer, manager)
    err = ipcServer.Launch()
    if err != nil {
        g_err_logger.Printf("Error: %v\n", err)
        os.Exit(1)
    }
    defer ipcServer.Stop()
    <commit_msg>Issue #16: Check g_err_logger for nil.<commit_after>package main

import (
    "os"
    "os/signal"
    "syscall"
    "log/syslog"
)

var g_logger, _ = syslog.NewLogger(syslog.LOG_NOTICE | syslog.LOG_CRON, 0)
var g_err_logger, _ = syslog.NewLogger(syslog.LOG_ERR | syslog.LOG_CRON, 0)

func stopServerOnSignal(server *IpcServer, jm *JobManager) {
    // Set up channel on which to send signal notifications.
	// We must use a buffered channel or risk missing the signal
	// if we're not ready to receive when the signal is sent.
	c := make(chan os.Signal, 1)
	signal.Notify(c, os.Interrupt, syscall.SIGTERM, os.Kill)

	// Block until a signal is received.
	<-c
	g_logger.Printf("Got signal.\n")
	server.Stop()
	jm.Cancel()
	jm.Wait()
	os.Exit(0)
}

func main() {
    var err error
    
    // run them
	manager, err := NewJobManager()
	if err != nil {
        if g_err_logger != nil {
            g_err_logger.Printf("Error: %v\n", err)
        }
        os.Exit(1)
    }
	cmdChan, err := manager.Launch()
	if err != nil {
        if g_err_logger != nil {
            g_err_logger.Printf("Error: %v\n", err)
        }
        os.Exit(1)
    }
    
    // make IPC server
    ipcServer := NewIpcServer(cmdChan)
    go stopServerOnSignal(ipcServer, manager)
    err = ipcServer.Launch()
    if err != nil {
        if g_err_logger != nil {
            g_err_logger.Printf("Error: %v\n", err)
        }
        os.Exit(1)
    }
    defer ipcServer.Stop()
    
{'fraction_non_alphanumeric': 0.12782228696285505, 'fraction_numerical': 0.005826656955571741, 'mean_word_length': 2.544516129032258, 'pattern_counts': {'":': 0, '<': 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': '1632857', 'n_tokens_mistral': 1034, 'n_tokens_neox': 1001, 'n_words': 254}