Completely re-work the server configuration to be separated out better
This commit is contained in:
@@ -64,7 +64,7 @@ func postServerPower(c *gin.Context) {
|
||||
//
|
||||
// We don't really care about any of the other actions at this point, they'll all result
|
||||
// in the process being stopped, which should have happened anyways if the server is suspended.
|
||||
if (data.Action == "start" || data.Action == "restart") && s.Suspended {
|
||||
if (data.Action == "start" || data.Action == "restart") && s.IsSuspended() {
|
||||
c.AbortWithStatusJSON(http.StatusBadRequest, gin.H{
|
||||
"error": "Cannot start or restart a server that is suspended.",
|
||||
})
|
||||
@@ -162,7 +162,7 @@ func deleteServer(c *gin.Context) {
|
||||
|
||||
// Immediately suspend the server to prevent a user from attempting
|
||||
// to start it while this process is running.
|
||||
s.Suspended = true
|
||||
s.Config().SetSuspended(true)
|
||||
|
||||
// If the server is currently installing, abort it.
|
||||
if s.IsInstalling() {
|
||||
|
||||
@@ -247,19 +247,7 @@ func (h *Handler) HandleInbound(m Message) error {
|
||||
if state == server.ProcessOfflineState {
|
||||
_ = h.server.Filesystem.HasSpaceAvailable()
|
||||
|
||||
h.server.Resources.RLock()
|
||||
defer h.server.Resources.RUnlock()
|
||||
|
||||
resources := server.ResourceUsage{
|
||||
Memory: 0,
|
||||
MemoryLimit: 0,
|
||||
CpuAbsolute: 0.0,
|
||||
Disk: h.server.Resources.Disk,
|
||||
}
|
||||
resources.Network.RxBytes = 0
|
||||
resources.Network.TxBytes = 0
|
||||
|
||||
b, _ := json.Marshal(resources)
|
||||
b, _ := json.Marshal(h.server.Proc())
|
||||
h.SendJson(&Message{
|
||||
Event: server.StatsEvent,
|
||||
Args: []string{string(b)},
|
||||
|
||||
Reference in New Issue
Block a user