mirror of
https://github.com/statbate/special-pancake.git
synced 2026-08-11 03:12:42 +00:00
update
This commit is contained in:
parent
fd9906d0c1
commit
a95e549f4d
3 changed files with 33 additions and 7 deletions
16
app/main.go
16
app/main.go
|
|
@ -28,6 +28,8 @@ var (
|
|||
Mysql, Clickhouse *sqlx.DB
|
||||
|
||||
json = jsoniter.ConfigCompatibleWithStandardLibrary
|
||||
|
||||
socketServer = make(chan []byte, 100)
|
||||
|
||||
save = make(chan saveData, 100)
|
||||
slog = make(chan saveLog, 100)
|
||||
|
|
@ -54,6 +56,7 @@ func main() {
|
|||
go announceCount()
|
||||
go saveDB()
|
||||
go saveLogs()
|
||||
go socketHandler()
|
||||
|
||||
http.HandleFunc("/cmd/", cmdHandler)
|
||||
http.HandleFunc("/list/", listHandler)
|
||||
|
|
@ -88,6 +91,19 @@ func initClickhouse() {
|
|||
Clickhouse = db
|
||||
}
|
||||
|
||||
func socketHandler() {
|
||||
for {
|
||||
select {
|
||||
case b := <-socketServer:
|
||||
conn, err := net.Dial("unix", "/tmp/echo.sock")
|
||||
if err == nil {
|
||||
conn.Write(b)
|
||||
conn.Close()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func randInt(min int, max int) int {
|
||||
return min + rand.Intn(max-min)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue