mirror of
https://github.com/FrankerFaceZ/FrankerFaceZ.git
synced 2025-08-03 00:18:31 +00:00
lol commit messages
This commit is contained in:
parent
e9801e6ca3
commit
74bc15e0e9
8 changed files with 117 additions and 31 deletions
47
socketserver/cmd/ffzsocketserver/console.go
Normal file
47
socketserver/cmd/ffzsocketserver/console.go
Normal file
|
@ -0,0 +1,47 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"../../internal/server"
|
||||
"fmt"
|
||||
"github.com/abiosoft/ishell"
|
||||
"runtime"
|
||||
)
|
||||
|
||||
func commandLineConsole() {
|
||||
|
||||
shell := ishell.NewShell()
|
||||
|
||||
shell.Register("clientcount", func(args ...string) (string, error) {
|
||||
server.GlobalSubscriptionInfo.RLock()
|
||||
count := len(server.GlobalSubscriptionInfo.Members)
|
||||
server.GlobalSubscriptionInfo.RUnlock()
|
||||
return fmt.Sprintln(count, "clients connected"), nil
|
||||
})
|
||||
|
||||
shell.Register("globalnotice", func(args ...string) (string, error) {
|
||||
msg := server.ClientMessage{
|
||||
MessageID: -1,
|
||||
Command: "message",
|
||||
Arguments: args[0],
|
||||
}
|
||||
server.PublishToAll(msg)
|
||||
return "Message sent.", nil
|
||||
})
|
||||
|
||||
shell.Register("memstatsbysize", func(args ...string) (string, error) {
|
||||
runtime.GC()
|
||||
|
||||
m := runtime.MemStats{}
|
||||
runtime.ReadMemStats(&m)
|
||||
for _, val := range m.BySize {
|
||||
if val.Mallocs == 0 {
|
||||
continue
|
||||
}
|
||||
shell.Println(val.Size, "bytes:", val.Mallocs, "allocs", val.Frees, "frees")
|
||||
}
|
||||
shell.Println(m.NumGC, "collections occurred")
|
||||
return "", nil
|
||||
})
|
||||
|
||||
shell.Start()
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue