Skip to content

Conversation

michelroegl-brunner
Copy link
Member

🚀 Real-time Update Progress Implementation

This PR implements a comprehensive real-time update progress system that keeps the modal open until the server restarts after an update.

✨ Features

Real-time Log Streaming:

  • Polling-based approach (1-second intervals) instead of WebSocket subscriptions
  • ANSI color code stripping for clean log display
  • Terminal-style output with proper dark mode support
  • Auto-scrolling log display

Smart Completion Detection:

  • Detects specific completion indicators in logs:
    • Service enabled and started successfully
    • Service is running
    • Update completed successfully
  • Only triggers reconnection when update is actually complete

Conservative Fallback Logic:

  • Waits at least 3 minutes before considering fallback reconnection
  • Requires 60 seconds of log silence before assuming server restart
  • Prevents premature modal closing during dependency installation

Improved Theming:

  • Fixed CSS specificity issues with !important for bg-card class
  • Updated all colors to use CSS variables for consistency
  • Proper dark mode support throughout the modal
  • Terminal-style log output with dark background and green text

🔧 Technical Changes

Backend (version.ts):

  • Added getUpdateLogs query with completion detection
  • Stripped ANSI codes from log output
  • Enhanced completion indicators

Frontend (VersionDisplay.tsx):

  • Replaced subscription with polling-based log fetching
  • Added smart reconnection logic with timing controls
  • Updated UI to use CSS variables
  • Improved modal theming and layout

Styling (globals.css):

  • Added !important to bg-card class for proper theming
  • Ensured CSS variables take precedence over Tailwind defaults

🎯 User Experience

  • Modal stays open during entire update process
  • Real-time progress visibility
  • No premature "server restarting" messages
  • Automatic page reload when server comes back online
  • Consistent theming with application design system

🧪 Testing

  • Tested with full update cycle including dependency installation
  • Verified proper completion detection
  • Confirmed dark mode theming works correctly
  • Validated reconnection logic timing

- Use setsid and nohup to completely detach update process from parent Node.js
- Add 3-second grace period to allow parent process to respond to client
- Fix issue where update script would stop when killing Node.js process
- Improve systemd service detection using systemctl status with exit code check
- Check for --relocated flag at the start of main() before any other logic
- Set PVE_UPDATE_RELOCATED environment variable immediately when --relocated is detected
- Prevents relocated script from triggering relocation logic again
…lation

- Primary: Use systemd-run --user --scope with KillMode=none for complete isolation
- Fallback: Implement double-fork daemonization technique
- Ensures update script survives systemd service shutdown
- Script is fully orphaned and reparented to init/systemd
@michelroegl-brunner michelroegl-brunner requested a review from a team as a code owner October 8, 2025 08:39
@michelroegl-brunner michelroegl-brunner merged commit 6a84da5 into main Oct 8, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant