<commit_before>package main

import (
  "os"
  "fmt"
  "time"
  ioutil "io/ioutil"
  http "net/http"
)

// HealthBadCount suck it
var HealthBadCount = 0

func statusServer() {
    http.HandleFunc("/ping", pingHandle)
    http.HandleFunc("/health", healthHandle)
    http.HandleFunc("/healthBad", healthBadHandle)
    http.HandleFunc("/pvDataReturn", pvDataReturn)
    http.HandleFunc("/pvDataSet", pvDataSet)

    //  create server that doesn't leave things open forever
    s := &http.Server{
            Addr:           ":8080",
            ReadTimeout:    10 * time.Second,
            WriteTimeout:   10 * time.Second,
        }
    s.ListenAndServe()
}

func pingHandle(w http.ResponseWriter, r *http.Request){
    if r.Method == "GET" {
        fmt.Fprintf(w, "PONG\n")
    }
}

func healthHandle(w http.ResponseWriter, r *http.Request){
    if r.Method == "GET" {
        fmt.Fprintf(w, "health\n")
    }
}

func pvDataReturn(w http.ResponseWriter, r *http.Request){
    if r.Method == "GET" {
        pvData, err := ioutil.ReadFile("/mnt/cephfs/pvData")
        if err != nil {
            fmt.Fprintf(w, "PV not present\n")
        } else {
            fmt.Fprintf(w, string(pvData[:]) + "\n")
        }
    }
}

func pvDataSet(w http.ResponseWriter, r *http.Request){
    if r.Method == "PUT" {
        bytes := make([]byte, 100)
        _, err := r.Body.Read(bytes)
        if err != nil {
            w.WriteHeader(http.StatusInternalServerError)            
            fmt.Fprintf(w, "Failed to read PUT data\n")
        }
        
        err = ioutil.WriteFile("/mnt/cephfs/pvData", bytes, os.ModePerm)
        if err != nil {
            w.WriteHeader(http.StatusInternalServerError)
            fmt.Fprintf(w, "PV not present\n")
        } else {
            fmt.Fprintf(w, "Data saved")
        }
    }
}

func healthBadHandle(w http.ResponseWriter, r *http.Request){
    if r.Method == "GET" {
        HealthBadCount++
        if HealthBadCount > 15 {
            w.WriteHeader(http.StatusInternalServerError)
        }
        fmt.Fprintf(w, "health count %d next\n", HealthBadCount)
    }
}

func main() {
    statusServer()
}<commit_msg>add some of them log messages<commit_after>package main

import (
  "os"
  "fmt"
  "time"
  ioutil "io/ioutil"
  http "net/http"
)

// HealthBadCount suck it
var HealthBadCount = 0

func statusServer() {
    http.HandleFunc("/ping", pingHandle)
    http.HandleFunc("/health", healthHandle)
    http.HandleFunc("/healthBad", healthBadHandle)
    http.HandleFunc("/pvDataReturn", pvDataReturn)
    http.HandleFunc("/pvDataSet", pvDataSet)

    //  create server that doesn't leave things open forever
    s := &http.Server{
            Addr:           ":8080",
            ReadTimeout:    10 * time.Second,
            WriteTimeout:   10 * time.Second,
        }
    s.ListenAndServe()
}

func pingHandle(w http.ResponseWriter, r *http.Request){
    if r.Method == "GET" {
        fmt.Fprintf(w, "PONG\n")
    }
}

func healthHandle(w http.ResponseWriter, r *http.Request){
    if r.Method == "GET" {
        fmt.Fprintf(w, "health\n")
    }
}

func pvDataReturn(w http.ResponseWriter, r *http.Request){
    if r.Method == "GET" {
        pvData, err := ioutil.ReadFile("/mnt/cephfs/pvData")
        if err != nil {
            fmt.Fprintf(w, "PV not present\n")
        } else {
            fmt.Fprintf(w, string(pvData[:]) + "\n")
        }
    }
}

func pvDataSet(w http.ResponseWriter, r *http.Request){
    if r.Method == "PUT" {
        bytes := make([]byte, 100)
        _, err := r.Body.Read(bytes)
        if err != nil {
            w.WriteHeader(http.StatusInternalServerError)            
            fmt.Fprintf(w, "Failed to read PUT data\n")
        }
        
        err = ioutil.WriteFile("/mnt/cephfs/pvData", bytes, os.ModePerm)
        if err != nil {
            w.WriteHeader(http.StatusInternalServerError)
            fmt.Fprintf(w, "PV not present\n")
        } else {
            fmt.Fprintf(w, "Data saved")
        }
    }
}

func healthBadHandle(w http.ResponseWriter, r *http.Request){
    if r.Method == "GET" {
        HealthBadCount++
        if HealthBadCount > 15 {
            w.WriteHeader(http.StatusInternalServerError)
        }
        fmt.Fprintf(w, "health count %d next\n", HealthBadCount)
    }
}

func namedOutput(filehandle *os.File) {
    counter := 0
    for {
        time.Sleep(time.Second)
        fmt.Fprintf(filehandle, "oh look!  a message on %s! id:  %d\n", filehandle.Name(), counter)
        counter++
    }
}

func main() {
    custom, err := os.Create("/lorst")
    if err != nil {
        fmt.Fprintln(os.Stderr, "Failed to open custom log handle")
    } else {
        go namedOutput(custom)
    }
    go namedOutput(os.Stderr)
    go namedOutput(os.Stdout)
    statusServer()
}
{'fraction_non_alphanumeric': 0.1373202750573036, 'fraction_numerical': 0.0060429256095019795, 'mean_word_length': 2.1516743269862113, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 5, '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': '4499255', 'n_tokens_mistral': 1618, 'n_tokens_neox': 1582, 'n_words': 344}