Add emitters for install started/stopped

This commit is contained in:
Dane Everitt 2020-07-29 21:39:27 -07:00
parent f0d6f67c6b
commit 7f9ec4402a
No known key found for this signature in database
GPG Key ID: EEA66103B3D71F53
3 changed files with 17 additions and 6 deletions

View File

@ -43,6 +43,8 @@ func (h *Handler) ListenForServerEvents(ctx context.Context) {
server.StatusEvent, server.StatusEvent,
server.ConsoleOutputEvent, server.ConsoleOutputEvent,
server.InstallOutputEvent, server.InstallOutputEvent,
server.InstallStartedEvent,
server.InstallCompletedEvent,
server.DaemonMessageEvent, server.DaemonMessageEvent,
server.BackupCompletedEvent, server.BackupCompletedEvent,
} }

View File

@ -9,12 +9,14 @@ import (
// Defines all of the possible output events for a server. // Defines all of the possible output events for a server.
// noinspection GoNameStartsWithPackageName // noinspection GoNameStartsWithPackageName
const ( const (
DaemonMessageEvent = "daemon message" DaemonMessageEvent = "daemon message"
InstallOutputEvent = "install output" InstallOutputEvent = "install output"
ConsoleOutputEvent = "console output" InstallStartedEvent = "install started"
StatusEvent = "status" InstallCompletedEvent = "install completed"
StatsEvent = "stats" ConsoleOutputEvent = "console output"
BackupCompletedEvent = "backup completed" StatusEvent = "status"
StatsEvent = "stats"
BackupCompletedEvent = "backup completed"
) )
type Event struct { type Event struct {

View File

@ -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() err := s.internalInstall()
s.Log().Debug("notifying panel of server install state") 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") 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 return err
} }