From 14a042ce8cdf60dc1ca7619a4e79102898289e9f Mon Sep 17 00:00:00 2001 From: robviren Date: Tue, 24 May 2022 16:20:53 -0500 Subject: [PATCH] Added Status --- README.md | 3 ++- handlers.go | 18 ++++++++++++++++++ main.go | 2 +- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ff87c3b..a9a3983 100644 --- a/README.md +++ b/README.md @@ -3,4 +3,5 @@ This tool allows for the simple configuration, backup, and starting of a V Risin - [x] Backup Saves - [x] Update -- [x] Upload Config Files \ No newline at end of file +- [x] Upload Config Files +- [x] Check if Server Runnning \ No newline at end of file diff --git a/handlers.go b/handlers.go index 8e57af7..834a632 100644 --- a/handlers.go +++ b/handlers.go @@ -120,3 +120,21 @@ func configure(c *gin.Context) { check(err) c.Data(http.StatusOK, "text/html", updated_page) } + +func isRunning(c *gin.Context) { + cmd := exec.Command("ps", "aux") + var out bytes.Buffer + cmd.Stdout = &out + + err := cmd.Run() + check(err) + + haystack := out.String() + var ret string + if strings.Contains(haystack, "VRisingServer.exe") { + ret = "true" + } else { + ret = "false" + } + c.String(http.StatusOK, ret, nil) +} diff --git a/main.go b/main.go index 0457bc1..dd29e2a 100644 --- a/main.go +++ b/main.go @@ -15,7 +15,6 @@ import ( var indexHTML embed.FS func main() { - //For General File Storage os.MkdirAll("data", 0755) @@ -23,6 +22,7 @@ func main() { r.GET("/", index) r.GET("/api/update", update) + r.GET("/api/status", isRunning) r.GET("/backup.zip", backup) r.POST("/configure", configure)