Add uptime command
parent
a6142d48ef
commit
4883552ecc
|
@ -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)
|
||||||
|
|
|
@ -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)
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue