mirror of
https://github.com/FrankerFaceZ/FrankerFaceZ.git
synced 2025-08-06 06:10:54 +00:00
lmao time.UnixDate sounds like a great idea doesn't it
This commit is contained in:
parent
b22efabfed
commit
1a709d6e51
3 changed files with 17 additions and 10 deletions
|
@ -1,12 +1,12 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/clarkduvall/hyperloglog"
|
"../../server"
|
||||||
|
"encoding/gob"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"../../server"
|
"github.com/clarkduvall/hyperloglog"
|
||||||
"net/http"
|
"net/http"
|
||||||
"encoding/gob"
|
|
||||||
"os"
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -40,10 +40,6 @@ func main() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if *forceWrite {
|
|
||||||
ForceWrite()
|
|
||||||
}
|
|
||||||
|
|
||||||
filename := flag.Arg(0)
|
filename := flag.Arg(0)
|
||||||
hll, err := DownloadAll(filename)
|
hll, err := DownloadAll(filename)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -70,6 +66,12 @@ func DownloadAll(filename string) (*hyperloglog.HyperLogLogPlus, error) {
|
||||||
result, _ := hyperloglog.NewPlus(server.CounterPrecision)
|
result, _ := hyperloglog.NewPlus(server.CounterPrecision)
|
||||||
|
|
||||||
for _, server := range SERVERS {
|
for _, server := range SERVERS {
|
||||||
|
if *forceWrite {
|
||||||
|
resp, err := http.Get(fmt.Sprintf("%s/hll_force_write", server))
|
||||||
|
if err == nil {
|
||||||
|
resp.Body.Close()
|
||||||
|
}
|
||||||
|
}
|
||||||
singleHLL, err := DownloadHLL(fmt.Sprintf("%s%s%s", server, folderPrefix, filename))
|
singleHLL, err := DownloadHLL(fmt.Sprintf("%s%s%s", server, folderPrefix, filename))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
|
@ -241,11 +241,13 @@ func HTTPBackendCachedPublish(w http.ResponseWriter, r *http.Request) {
|
||||||
channel := formData.Get("channel")
|
channel := formData.Get("channel")
|
||||||
deleteMode := formData.Get("delete") != ""
|
deleteMode := formData.Get("delete") != ""
|
||||||
timeStr := formData.Get("time")
|
timeStr := formData.Get("time")
|
||||||
timestamp, err := time.Parse(time.UnixDate, timeStr)
|
timeNum, err := strconv.ParseInt(timeStr, 10, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
w.WriteHeader(422)
|
w.WriteHeader(422)
|
||||||
fmt.Fprintf(w, "error parsing time: %v", err)
|
fmt.Fprintf(w, "error parsing time: %v", err)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
timestamp := time.Unix(timeNum, 0)
|
||||||
|
|
||||||
cacheinfo, ok := S2CCommandsCacheInfo[cmd]
|
cacheinfo, ok := S2CCommandsCacheInfo[cmd]
|
||||||
if !ok {
|
if !ok {
|
||||||
|
|
|
@ -6,9 +6,9 @@ import (
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"encoding/gob"
|
"encoding/gob"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -160,6 +160,7 @@ func writeAllHLLs() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
var hllFileServer = http.StripPrefix("/hll", http.FileServer(http.Dir(uniqCountDir)))
|
var hllFileServer = http.StripPrefix("/hll", http.FileServer(http.Dir(uniqCountDir)))
|
||||||
|
|
||||||
func HTTPShowHLL(w http.ResponseWriter, r *http.Request) {
|
func HTTPShowHLL(w http.ResponseWriter, r *http.Request) {
|
||||||
hllFileServer.ServeHTTP(w, r)
|
hllFileServer.ServeHTTP(w, r)
|
||||||
}
|
}
|
||||||
|
@ -239,7 +240,9 @@ func getNextMidnight() time.Time {
|
||||||
// is_init_func
|
// is_init_func
|
||||||
func rolloverCounters() {
|
func rolloverCounters() {
|
||||||
for {
|
for {
|
||||||
time.Sleep(getNextMidnight().Sub(time.Now()))
|
duration := getNextMidnight().Sub(time.Now())
|
||||||
|
// fmt.Println(duration)
|
||||||
|
time.Sleep(duration)
|
||||||
rolloverCounters_do()
|
rolloverCounters_do()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue