add logs
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"io"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"time"
|
||||
@@ -166,6 +167,7 @@ func (as ConfigService) GetConfig(ctx *fiber.Ctx) (interface{}, error) {
|
||||
server := as.serverRepository.GetFirst(ctx.UserContext(), serverID)
|
||||
|
||||
if server == nil {
|
||||
log.Print("Server not found")
|
||||
return nil, fiber.NewError(404, "Server not found")
|
||||
}
|
||||
|
||||
@@ -190,6 +192,7 @@ func (as ConfigService) GetConfigs(ctx *fiber.Ctx) (*model.Configurations, error
|
||||
server := as.serverRepository.GetFirst(ctx.UserContext(), serverID)
|
||||
|
||||
if server == nil {
|
||||
log.Print("Server not found")
|
||||
return nil, fiber.NewError(404, "Server not found")
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package service
|
||||
import (
|
||||
"acc-server-manager/local/model"
|
||||
"acc-server-manager/local/repository"
|
||||
"log"
|
||||
|
||||
"github.com/gofiber/fiber/v2"
|
||||
)
|
||||
@@ -30,7 +31,10 @@ func (as ServerService) GetAll(ctx *fiber.Ctx) *[]model.Server {
|
||||
servers := as.repository.GetAll(ctx.UserContext())
|
||||
|
||||
for i, server := range *servers {
|
||||
status, _ := as.apiService.StatusServer(server.ServiceName)
|
||||
status, err := as.apiService.StatusServer(server.ServiceName)
|
||||
if err != nil {
|
||||
log.Print(err.Error())
|
||||
}
|
||||
(*servers)[i].Status = model.ServiceStatus(status)
|
||||
}
|
||||
|
||||
@@ -46,7 +50,10 @@ func (as ServerService) GetAll(ctx *fiber.Ctx) *[]model.Server {
|
||||
// string: Application version
|
||||
func (as ServerService) GetById(ctx *fiber.Ctx, serverID int) *model.Server {
|
||||
server := as.repository.GetFirst(ctx.UserContext(), serverID)
|
||||
status, _ := as.apiService.StatusServer(server.ServiceName)
|
||||
status, err := as.apiService.StatusServer(server.ServiceName)
|
||||
if err != nil {
|
||||
log.Print(err.Error())
|
||||
}
|
||||
server.Status = model.ServiceStatus(status)
|
||||
|
||||
return server
|
||||
|
||||
Reference in New Issue
Block a user