1
0
Fork 0
mirror of https://github.com/FrankerFaceZ/FrankerFaceZ.git synced 2025-08-08 07:10:54 +00:00

flag.Arg(0) not flag.Arg(1) you dummy

This commit is contained in:
Kane York 2015-12-23 23:54:03 -08:00
parent daeb9d1a06
commit b22efabfed

View file

@ -8,7 +8,6 @@ import (
"net/http" "net/http"
"encoding/gob" "encoding/gob"
"os" "os"
"github.com/satori/go.uuid"
) )
var SERVERS = []string{ var SERVERS = []string{
@ -31,6 +30,8 @@ Filename should be in one of the following formats:
monthly-12-2015.gob monthly-12-2015.gob
` `
var forceWrite = flag.Bool("f", false, "force servers to write out their current")
func main() { func main() {
flag.Parse() flag.Parse()
if flag.NArg() < 1 { if flag.NArg() < 1 {
@ -38,9 +39,12 @@ func main() {
os.Exit(2) os.Exit(2)
return return
} }
gob.RegisterName("hyperloglog", hyperloglog.HyperLogLogPlus{})
filename := flag.Arg(1) if *forceWrite {
ForceWrite()
}
filename := flag.Arg(0)
hll, err := DownloadAll(filename) hll, err := DownloadAll(filename)
if err != nil { if err != nil {
fmt.Println(err) fmt.Println(err)
@ -51,6 +55,17 @@ func main() {
fmt.Println(hll.Count()) fmt.Println(hll.Count())
} }
func ForceWrite() {
for _, server := range SERVERS {
resp, err := http.Get(fmt.Sprintf("%s/hll_force_write", server))
if err != nil {
fmt.Println(err)
os.Exit(1)
}
resp.Body.Close()
}
}
func DownloadAll(filename string) (*hyperloglog.HyperLogLogPlus, error) { func DownloadAll(filename string) (*hyperloglog.HyperLogLogPlus, error) {
result, _ := hyperloglog.NewPlus(server.CounterPrecision) result, _ := hyperloglog.NewPlus(server.CounterPrecision)