diff --git a/controller/update.go b/controller/update.go index 40d9bd4..fec07b5 100644 --- a/controller/update.go +++ b/controller/update.go @@ -55,9 +55,10 @@ func UpdateApp(server *socketio.Server) <-chan string { server.BroadcastToRoom("/", "update", "updateLogs", msg) // 1. Stop services + pool stopService("LSTV2") + time.Sleep(1 * time.Second) stopService("lst_app") - stopAppPool("LogisticsSupportTool") - time.Sleep(2 * time.Second) + //stopAppPool("LogisticsSupportTool") + time.Sleep(1 * time.Second) msg = "Checking cleanup of files" updates <- msg @@ -104,8 +105,10 @@ func UpdateApp(server *socketio.Server) <-chan string { updates <- msg server.BroadcastToRoom("/", "update", "updateLogs", msg) startService("lst_app") + time.Sleep(2 * time.Second) startService("LSTV2") - startAppPool("LogisticsSupportTool") + time.Sleep(2 * time.Second) + //startAppPool("LogisticsSupportTool") if err := os.Remove(zips[0]); err != nil { msg = fmt.Sprintf("warning: failed to delete zip %s: %v", zips[0], err) diff --git a/controller/update_channel.go b/controller/update_channel.go index d3cc824..53956c4 100644 --- a/controller/update_channel.go +++ b/controller/update_channel.go @@ -11,7 +11,6 @@ import ( "os" "strings" - "github.com/gin-gonic/gin" 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") return } - + log.Printf("Host value: [%q]", host) 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.") - 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 } @@ -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") return } 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}) } } @@ -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) - } -}