mirror of
https://github.com/FrankerFaceZ/FrankerFaceZ.git
synced 2025-08-06 22:30:57 +00:00
lol changing a server into a script
This commit is contained in:
parent
e1e26f5288
commit
74270245ab
3 changed files with 50 additions and 17 deletions
|
@ -11,7 +11,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var SERVERS = []string{
|
var SERVERS = []string{
|
||||||
// "https://catbag.frankerfacez.com",
|
"https://catbag.frankerfacez.com",
|
||||||
"https://andknuckles.frankerfacez.com",
|
"https://andknuckles.frankerfacez.com",
|
||||||
"https://tuturu.frankerfacez.com",
|
"https://tuturu.frankerfacez.com",
|
||||||
}
|
}
|
||||||
|
|
|
@ -171,7 +171,7 @@ func (si *serverInfo) GetHLL(at time.Time) (*hyperloglog.HyperLogLogPlus, error)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// continue to download
|
// continue to download
|
||||||
} else {
|
} else {
|
||||||
fmt.Printf("opened hll %s:%s\n", si.subdomain, getHLLCacheKey(at))
|
//fmt.Printf("opened hll %s:%s\n", si.subdomain, getHLLCacheKey(at))
|
||||||
return loadHLLFromStream(reader)
|
return loadHLLFromStream(reader)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,17 +1,19 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
|
||||||
"flag"
|
|
||||||
"github.com/clarkduvall/hyperloglog"
|
|
||||||
"time"
|
|
||||||
"bitbucket.org/stendec/frankerfacez/socketserver/server"
|
|
||||||
"net/url"
|
|
||||||
"fmt"
|
|
||||||
"strings"
|
|
||||||
"errors"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
|
"flag"
|
||||||
|
"fmt"
|
||||||
|
"net/http"
|
||||||
|
"net/url"
|
||||||
|
"os"
|
||||||
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"bitbucket.org/stendec/frankerfacez/socketserver/server"
|
||||||
|
"github.com/clarkduvall/hyperloglog"
|
||||||
)
|
)
|
||||||
|
|
||||||
var configLocation = flag.String("config", "./config.json", "Location of the configuration file. Defaults to ./config.json")
|
var configLocation = flag.String("config", "./config.json", "Location of the configuration file. Defaults to ./config.json")
|
||||||
|
@ -39,10 +41,41 @@ func main() {
|
||||||
allServers[i].Setup(v)
|
allServers[i].Setup(v)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
printEveryDay()
|
||||||
|
os.Exit(0)
|
||||||
http.HandleFunc("/api/get", ServeAPIGet)
|
http.HandleFunc("/api/get", ServeAPIGet)
|
||||||
http.ListenAndServe(config.ListenAddr, http.DefaultServeMux)
|
http.ListenAndServe(config.ListenAddr, http.DefaultServeMux)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func printEveryDay() {
|
||||||
|
year := 2015
|
||||||
|
month := 12
|
||||||
|
day := 23
|
||||||
|
filter := serverFilterAll
|
||||||
|
var filter1, filter2, filter3 serverFilter
|
||||||
|
filter1.Mode = serverFilterModeWhitelist
|
||||||
|
filter2.Mode = serverFilterModeWhitelist
|
||||||
|
filter3.Mode = serverFilterModeWhitelist
|
||||||
|
filter1.Add(allServers[0].subdomain)
|
||||||
|
filter2.Add(allServers[1].subdomain)
|
||||||
|
filter3.Add(allServers[2].subdomain)
|
||||||
|
stopTime := time.Now()
|
||||||
|
var at time.Time
|
||||||
|
const timeFmt = "2006-01-02"
|
||||||
|
for ; stopTime.After(at); day++ {
|
||||||
|
at = time.Date(year, time.Month(month), day, 0, 0, 0, 0, server.CounterLocation)
|
||||||
|
hll, _ := hyperloglog.NewPlus(server.CounterPrecision)
|
||||||
|
hll1, _ := hyperloglog.NewPlus(server.CounterPrecision)
|
||||||
|
hll2, _ := hyperloglog.NewPlus(server.CounterPrecision)
|
||||||
|
hll3, _ := hyperloglog.NewPlus(server.CounterPrecision)
|
||||||
|
addSingleDate(at, filter, hll)
|
||||||
|
addSingleDate(at, filter1, hll1)
|
||||||
|
addSingleDate(at, filter2, hll2)
|
||||||
|
addSingleDate(at, filter3, hll3)
|
||||||
|
fmt.Printf("%s\t%d\t%d\t%d\t%d\n", at.Format(timeFmt), hll.Count(), hll1.Count(), hll2.Count(), hll3.Count())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const RequestURIName = "q"
|
const RequestURIName = "q"
|
||||||
const separatorRange = "~"
|
const separatorRange = "~"
|
||||||
const separatorAdd = " "
|
const separatorAdd = " "
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue