fix(controller): touch ups on the update process to view more clean
This commit is contained in:
@@ -55,9 +55,10 @@ func UpdateApp(server *socketio.Server) <-chan string {
|
|||||||
server.BroadcastToRoom("/", "update", "updateLogs", msg)
|
server.BroadcastToRoom("/", "update", "updateLogs", msg)
|
||||||
// 1. Stop services + pool
|
// 1. Stop services + pool
|
||||||
stopService("LSTV2")
|
stopService("LSTV2")
|
||||||
|
time.Sleep(1 * time.Second)
|
||||||
stopService("lst_app")
|
stopService("lst_app")
|
||||||
stopAppPool("LogisticsSupportTool")
|
//stopAppPool("LogisticsSupportTool")
|
||||||
time.Sleep(2 * time.Second)
|
time.Sleep(1 * time.Second)
|
||||||
|
|
||||||
msg = "Checking cleanup of files"
|
msg = "Checking cleanup of files"
|
||||||
updates <- msg
|
updates <- msg
|
||||||
@@ -104,8 +105,10 @@ func UpdateApp(server *socketio.Server) <-chan string {
|
|||||||
updates <- msg
|
updates <- msg
|
||||||
server.BroadcastToRoom("/", "update", "updateLogs", msg)
|
server.BroadcastToRoom("/", "update", "updateLogs", msg)
|
||||||
startService("lst_app")
|
startService("lst_app")
|
||||||
|
time.Sleep(2 * time.Second)
|
||||||
startService("LSTV2")
|
startService("LSTV2")
|
||||||
startAppPool("LogisticsSupportTool")
|
time.Sleep(2 * time.Second)
|
||||||
|
//startAppPool("LogisticsSupportTool")
|
||||||
|
|
||||||
if err := os.Remove(zips[0]); err != nil {
|
if err := os.Remove(zips[0]); err != nil {
|
||||||
msg = fmt.Sprintf("warning: failed to delete zip %s: %v", zips[0], err)
|
msg = fmt.Sprintf("warning: failed to delete zip %s: %v", zips[0], err)
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
|
||||||
socketio "github.com/googollee/go-socket.io"
|
socketio "github.com/googollee/go-socket.io"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -55,10 +54,19 @@ func updateServer(server *socketio.Server, target string) {
|
|||||||
server.BroadcastToRoom("/", "update", "updateLogs", "Could not retrieve hostname")
|
server.BroadcastToRoom("/", "update", "updateLogs", "Could not retrieve hostname")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
log.Printf("Host value: [%q]", host)
|
||||||
if strings.Contains(host, "VMS") || strings.Contains(host, "vms") {
|
if strings.Contains(host, "VMS") || strings.Contains(host, "vms") {
|
||||||
server.BroadcastToRoom("/", "update", "updateLogs", "Your are about to check for a new build and then update the server.")
|
server.BroadcastToRoom("/", "update", "updateLogs", "Your are about to check for a new build and then update the server.")
|
||||||
go UpdateApp(server)
|
//go UpdateApp(server)
|
||||||
|
// Kick off the update
|
||||||
|
go func() {
|
||||||
|
updates := UpdateApp(server) // returns <-chan string
|
||||||
|
for msg := range updates {
|
||||||
|
fmt.Println(msg)
|
||||||
|
//server.BroadcastToRoom("/", "update", "updateLogs", msg)
|
||||||
|
}
|
||||||
|
|
||||||
|
}()
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -67,7 +75,7 @@ func updateServer(server *socketio.Server, target string) {
|
|||||||
server.BroadcastToRoom("/", "update", "updateLogs", "You seem to be on a dev server or not an actual production server, you MUST pass a server over. I.E. USMCD1VMS036")
|
server.BroadcastToRoom("/", "update", "updateLogs", "You seem to be on a dev server or not an actual production server, you MUST pass a server over. I.E. USMCD1VMS036")
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
server.BroadcastToRoom("/", "update", "updateLogs", fmt.Sprintf("Running the update on: %v", target))
|
server.BroadcastToRoom("/", "update", "updateLogs", fmt.Sprintf("Running remote update on: %v", target))
|
||||||
go triggerRemoteUpdate(server, target, UpdatePayload{Action: "update", Target: target})
|
go triggerRemoteUpdate(server, target, UpdatePayload{Action: "update", Target: target})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -116,16 +124,3 @@ func triggerRemoteUpdate(server *socketio.Server, remoteURL string, payload Upda
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func sendUpdate(c *gin.Context, flusher http.Flusher, server *socketio.Server, msg string) {
|
|
||||||
// SSE stream
|
|
||||||
if c != nil && flusher != nil {
|
|
||||||
fmt.Fprintf(c.Writer, "event: log\ndata: %s\n\n", msg)
|
|
||||||
flusher.Flush()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Socket.IO
|
|
||||||
if server != nil {
|
|
||||||
server.BroadcastToRoom("/", "update", "updateLogs", msg)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user