replace servers.servers singleton with server.Manager

This commit is contained in:
Jakob Schrettenbrunner
2021-01-08 23:14:56 +00:00
parent 94f4207d60
commit 8192244fec
16 changed files with 162 additions and 108 deletions

View File

@@ -9,7 +9,6 @@ import (
"github.com/gin-gonic/gin"
"github.com/pterodactyl/wings/config"
"github.com/pterodactyl/wings/installer"
"github.com/pterodactyl/wings/server"
"github.com/pterodactyl/wings/system"
)
@@ -28,7 +27,8 @@ func getSystemInformation(c *gin.Context) {
// Returns all of the servers that are registered and configured correctly on
// this wings instance.
func getAllServers(c *gin.Context) {
c.JSON(http.StatusOK, server.GetServers().All())
serverManager := ServerManagerFromContext(c)
c.JSON(http.StatusOK, serverManager.GetAll())
}
// Creates a new server on the wings daemon and begins the installation process
@@ -52,7 +52,8 @@ func postCreateServer(c *gin.Context) {
// Plop that server instance onto the request so that it can be referenced in
// requests from here-on out.
server.GetServers().Add(install.Server())
serverManager := ServerManagerFromContext(c)
serverManager.Add(install.Server())
// Begin the installation process in the background to not block the request
// cycle. If there are any errors they will be logged and communicated back