2019-04-21 00:38:12 +00:00
|
|
|
package server
|
|
|
|
|
2019-12-01 01:08:11 +00:00
|
|
|
import (
|
2020-08-11 04:38:42 +00:00
|
|
|
"github.com/pterodactyl/wings/events"
|
2022-02-03 00:16:34 +00:00
|
|
|
"github.com/pterodactyl/wings/system"
|
2019-12-01 01:08:11 +00:00
|
|
|
)
|
|
|
|
|
2022-11-15 01:25:01 +00:00
|
|
|
// Defines all the possible output events for a server.
|
2019-04-21 00:38:12 +00:00
|
|
|
const (
|
2021-01-31 02:43:35 +00:00
|
|
|
DaemonMessageEvent = "daemon message"
|
|
|
|
InstallOutputEvent = "install output"
|
|
|
|
InstallStartedEvent = "install started"
|
|
|
|
InstallCompletedEvent = "install completed"
|
|
|
|
ConsoleOutputEvent = "console output"
|
|
|
|
StatusEvent = "status"
|
|
|
|
StatsEvent = "stats"
|
|
|
|
BackupRestoreCompletedEvent = "backup restore completed"
|
|
|
|
BackupCompletedEvent = "backup completed"
|
|
|
|
TransferLogsEvent = "transfer logs"
|
|
|
|
TransferStatusEvent = "transfer status"
|
2022-11-15 01:25:01 +00:00
|
|
|
DeletedEvent = "deleted"
|
2019-04-21 00:38:12 +00:00
|
|
|
)
|
|
|
|
|
2022-02-03 00:16:34 +00:00
|
|
|
// Events returns the server's emitter instance.
|
2022-01-18 03:23:29 +00:00
|
|
|
func (s *Server) Events() *events.Bus {
|
2020-07-30 04:56:22 +00:00
|
|
|
s.emitterLock.Lock()
|
|
|
|
defer s.emitterLock.Unlock()
|
|
|
|
|
2020-01-18 22:04:26 +00:00
|
|
|
if s.emitter == nil {
|
2022-01-18 03:23:29 +00:00
|
|
|
s.emitter = events.NewBus()
|
2019-04-21 00:38:12 +00:00
|
|
|
}
|
2020-01-18 22:04:26 +00:00
|
|
|
|
|
|
|
return s.emitter
|
2019-04-21 00:38:12 +00:00
|
|
|
}
|
2022-02-03 00:16:34 +00:00
|
|
|
|
|
|
|
// Sink returns the instantiated and named sink for a server. If the sink has
|
|
|
|
// not been configured yet this function will cause a panic condition.
|
|
|
|
func (s *Server) Sink(name system.SinkName) *system.SinkPool {
|
|
|
|
sink, ok := s.sinks[name]
|
|
|
|
if !ok {
|
|
|
|
s.Log().Fatalf("attempt to access nil sink: %s", name)
|
|
|
|
}
|
|
|
|
return sink
|
|
|
|
}
|
|
|
|
|
|
|
|
// DestroyAllSinks iterates over all of the sinks configured for the server and
|
|
|
|
// destroys their instances. Note that this will cause a panic if you attempt
|
|
|
|
// to call Server.Sink() again after. This function is only used when a server
|
|
|
|
// is being deleted from the system.
|
|
|
|
func (s *Server) DestroyAllSinks() {
|
|
|
|
s.Log().Info("destroying all registered sinks for server instance")
|
|
|
|
for _, sink := range s.sinks {
|
|
|
|
sink.Destroy()
|
|
|
|
}
|
2022-02-23 22:01:03 +00:00
|
|
|
}
|