Add uptime command

master
HimbeerserverDE 2021-04-22 17:30:13 +02:00
parent a6142d48ef
commit 4883552ecc
No known key found for this signature in database
GPG Key ID: 1A651504791E6A8B
2 changed files with 12 additions and 0 deletions

View File

@ -2,6 +2,7 @@ package main
import ( import (
"log" "log"
"strconv"
"strings" "strings"
) )
@ -497,6 +498,14 @@ func init() {
SendChatMsg(c, "Unbanned "+param) SendChatMsg(c, "Unbanned "+param)
}) })
RegisterChatCommand("uptime",
"Prints the uptime of the proxy. Usage: uptime",
nil,
true,
func(c *Conn, param string) {
SendChatMsg(c, "Uptime: "+strconv.FormatFloat(Uptime(), 'f', -1, 64)+"s")
})
RegisterOnRedirectDone(func(c *Conn, newsrv string, success bool) { RegisterOnRedirectDone(func(c *Conn, newsrv string, success bool) {
if success { if success {
err := SetStorageKey("server:"+c.Username(), newsrv) err := SetStorageKey("server:"+c.Username(), newsrv)

View File

@ -1,6 +1,7 @@
package main package main
import ( import (
"log"
"os" "os"
"os/signal" "os/signal"
"syscall" "syscall"
@ -12,6 +13,8 @@ func init() {
signal.Notify(signalChan, os.Interrupt, syscall.SIGTERM) signal.Notify(signalChan, os.Interrupt, syscall.SIGTERM)
<-signalChan <-signalChan
log.Print("Caught SIGINT or SIGTERM, shutting down")
End(false, false) End(false, false)
}() }()
} }