From 4883552ecc7dc7fe5cbc0cfbdd93275a46f46a32 Mon Sep 17 00:00:00 2001 From: HimbeerserverDE Date: Thu, 22 Apr 2021 17:30:13 +0200 Subject: [PATCH] Add uptime command --- igutils.go | 9 +++++++++ signal.go | 3 +++ 2 files changed, 12 insertions(+) diff --git a/igutils.go b/igutils.go index 6dee2e8..634e885 100644 --- a/igutils.go +++ b/igutils.go @@ -2,6 +2,7 @@ package main import ( "log" + "strconv" "strings" ) @@ -497,6 +498,14 @@ func init() { 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) { if success { err := SetStorageKey("server:"+c.Username(), newsrv) diff --git a/signal.go b/signal.go index 6ec3315..61e7ff2 100644 --- a/signal.go +++ b/signal.go @@ -1,6 +1,7 @@ package main import ( + "log" "os" "os/signal" "syscall" @@ -12,6 +13,8 @@ func init() { signal.Notify(signalChan, os.Interrupt, syscall.SIGTERM) <-signalChan + log.Print("Caught SIGINT or SIGTERM, shutting down") + End(false, false) }() }