MCPcopy Create free account
hub / github.com/devnullvoid/pvetui / Shutdown

Method Shutdown

internal/vnc/session_manager.go:624–661  ·  view source on GitHub ↗

Shutdown gracefully shuts down the session manager and all active sessions. This should be called when the application is shutting down to ensure proper cleanup of resources.

()

Source from the content-addressed store, hash-verified

622// This should be called when the application is shutting down to ensure
623// proper cleanup of resources.
624func (sm *SessionManager) Shutdown() error {
625 sm.mutex.Lock()
626 defer sm.mutex.Unlock()
627
628 if sm.logger != nil {
629 sm.logger.Info("Shutting down VNC Session Manager: active_sessions=%d", len(sm.sessions))
630 }
631
632 // Stop the cleanup process
633 if sm.cleanupTicker != nil {
634 sm.cleanupTicker.Stop()
635 }
636
637 // Cancel the manager context
638 if sm.cancelFunc != nil {
639 sm.cancelFunc()
640 }
641
642 // Shut down all active sessions
643 var shutdownErrors []error
644
645 for sessionID, session := range sm.sessions {
646 if err := session.Shutdown(); err != nil {
647 shutdownErrors = append(shutdownErrors, fmt.Errorf("failed to shutdown session %s: %w", sessionID, err))
648 }
649 }
650
651 // Clear sessions and ports
652 sm.sessions = make(map[string]*VNCSession)
653 sm.usedPorts = make(map[int]bool)
654
655 // Return any shutdown errors
656 if len(shutdownErrors) > 0 {
657 return fmt.Errorf("encountered %d errors during shutdown: %v", len(shutdownErrors), shutdownErrors)
658 }
659
660 return nil
661}
662
663// findReusableSession finds an existing session that can be reused for the given target.
664// This method must be called with the manager mutex held.

Callers

nothing calls this directly

Calls 3

InfoMethod · 0.65
ShutdownMethod · 0.65
StopMethod · 0.45

Tested by

no test coverage detected