Skip to content

Conversation

@michelroegl-brunner
Copy link
Member

@michelroegl-brunner michelroegl-brunner commented Oct 7, 2025

Summary

This PR adds a complete web-based update system that allows updating the application directly from the web interface with proper process management and enhanced reliability.

New Features

1. Web-Based Update Execution

  • Added executeUpdate mutation that spawns the update script as a detached background process
  • Update script runs independently using nohup, allowing it to safely restart the server
  • Immediate response to the web interface while update continues in background
  • Automatic server restart after successful update

2. Robust Update Script Implementation

  • Implemented proper bash process substitution patterns for reliable file operations
  • Enhanced update_files() function with accurate file tracking and progress reporting
  • Improved clear_original_directory() function with proper variable scoping
  • Ensures all operations complete successfully without silent failures

3. Comprehensive Logging and Debugging

  • Detailed logging throughout the entire update process
  • Pre-download connectivity tests to GitHub API
  • Verbose curl output capture for troubleshooting network issues
  • Real-time progress indicators for file copying operations
  • Stage-by-stage status reporting with clear success/error messages
  • All logs written to /tmp/update.log for post-mortem analysis

Technical Implementation

Architecture: The update script spawns as a detached process, independent of the Node.js parent process. This allows it to:

  • Stop the running Node.js server without terminating itself
  • Download and apply updates while the server is offline
  • Rebuild and restart the application
  • Complete successfully without dependency on the web server

Process Flow:

  1. User clicks update button in web interface
  2. API spawns detached update script with nohup
  3. Script stops the application safely
  4. Downloads latest release from GitHub
  5. Backs up data and configuration
  6. Applies updates to application files
  7. Rebuilds the application
  8. Restarts the server automatically

Benefits

  • Seamless Updates: Users can update directly from the web interface
  • Zero Downtime: Automatic restart after update completion
  • Safe Operations: Detached process prevents premature termination
  • Full Visibility: Comprehensive logging for troubleshooting
  • Reliable Execution: Proper bash patterns ensure consistent behavior

Files Changed

  • src/server/api/routers/version.ts - Web-based update API endpoint
  • update.sh - Enhanced update script with robust process management and logging

@michelroegl-brunner michelroegl-brunner requested a review from a team as a code owner October 7, 2025 14:06
@michelroegl-brunner michelroegl-brunner changed the title Fix update script process management and subshell issues Add web-based update system with detached process management Oct 7, 2025
@michelroegl-brunner michelroegl-brunner merged commit 24430ee into main Oct 7, 2025
4 checks passed
@michelroegl-brunner michelroegl-brunner deleted the feat/version_handeling branch October 14, 2025 06:43
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.

2 participants