From 7f9ec4402abfc94d38d878493e44046f03cabf9e Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Wed, 29 Jul 2020 21:39:27 -0700 Subject: [PATCH] Add emitters for install started/stopped --- router/websocket/listeners.go | 2 ++ server/events.go | 14 ++++++++------ server/install.go | 7 +++++++ 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/router/websocket/listeners.go b/router/websocket/listeners.go index 124a85d..b1a99ac 100644 --- a/router/websocket/listeners.go +++ b/router/websocket/listeners.go @@ -43,6 +43,8 @@ func (h *Handler) ListenForServerEvents(ctx context.Context) { server.StatusEvent, server.ConsoleOutputEvent, server.InstallOutputEvent, + server.InstallStartedEvent, + server.InstallCompletedEvent, server.DaemonMessageEvent, server.BackupCompletedEvent, } diff --git a/server/events.go b/server/events.go index 5ea6ceb..425de25 100644 --- a/server/events.go +++ b/server/events.go @@ -9,12 +9,14 @@ import ( // Defines all of the possible output events for a server. // noinspection GoNameStartsWithPackageName const ( - DaemonMessageEvent = "daemon message" - InstallOutputEvent = "install output" - ConsoleOutputEvent = "console output" - StatusEvent = "status" - StatsEvent = "stats" - BackupCompletedEvent = "backup completed" + DaemonMessageEvent = "daemon message" + InstallOutputEvent = "install output" + InstallStartedEvent = "install started" + InstallCompletedEvent = "install completed" + ConsoleOutputEvent = "console output" + StatusEvent = "status" + StatsEvent = "stats" + BackupCompletedEvent = "backup completed" ) type Event struct { diff --git a/server/install.go b/server/install.go index 0d8fa93..54ebcfb 100644 --- a/server/install.go +++ b/server/install.go @@ -36,6 +36,9 @@ func (s *Server) Install(sync bool) error { } } + // Send the start event so the Panel can automatically update. + s.Events().Publish(InstallStartedEvent, "") + err := s.internalInstall() s.Log().Debug("notifying panel of server install state") @@ -52,6 +55,10 @@ func (s *Server) Install(sync bool) error { l.Warn("failed to notify panel of server install state") } + // Push an event to the websocket so we can auto-refresh the information in the panel once + // the install is completed. + s.Events().Publish(InstallCompletedEvent, "") + return err }