Skip to content

Add server maintenance script (update-server.sh) #140

@brainless

Description

@brainless

Problem

Currently, there is no dedicated script for server maintenance operations like system updates and reboots. Server administrators need to manually SSH and run commands, then manually verify services are back up.

Analysis of Current Scripts

Existing update functionality:

    • (initial setup only)
    • (only when build dependencies missing)
    • (only for certbot installation)

Existing monitoring:

    • Comprehensive service health checking script

Proposed Solution

Create that provides:

  1. System Updates

    • Package cleanup if needed
  2. Graceful Service Management

    • Stop LetsOrder service before reboot
    • Stop nginx if needed
  3. Reboot with Verification

    • Initiate reboot
    • Wait for server to come back online
    • Automatically run health checks using existing logic
  4. Post-Reboot Verification

    • Service status checks (letsorder, nginx)
    • Health endpoint verification
    • Resource usage monitoring

Technical Requirements

  • Follow existing script patterns (SSH_OPTS, colored output, error handling)
  • Use same configuration approach (SERVER_IP, SSH_KEY_PATH from .env or CLI)
  • Integrate with existing functionality
  • Handle SSH reconnection after reboot
  • Proper timeout handling for reboot process

Usage Example

./deployment/scripts/update-server.sh <server-ip> <ssh-key-path>
./deployment/scripts/update-server.sh  # Uses .env configuration

Files to Reference

  • �[0;31m[2025-08-31 09:19:36] ERROR: Usage: deployment/scripts/setup-server.sh �[0m - SSH patterns, apt commands
  • ==================================================
    LetsOrder Production Status Check
    ==================================================
    �[0;34m[2025-08-31 09:19:36] ℹ️ Checking local requirements...�[0m
    �[0;32m[2025-08-31 09:19:36] ✅ Local requirements satisfied�[0m
    �[0;34m[2025-08-31 09:19:36] ℹ️ Loading configuration from deployment/scripts/../.env�[0m
    �[0;34m[2025-08-31 09:19:36] ℹ️ Configuration:�[0m
    �[0;34m[2025-08-31 09:19:36] ℹ️ Server IP: 51.159.134.32�[0m
    �[0;34m[2025-08-31 09:19:36] ℹ️ Server Host: api.letsorder.app�[0m
    �[0;34m[2025-08-31 09:19:36] ℹ️ SSH Key: /home/brainless/.ssh/id_ed25519�[0m

�[0;34m[2025-08-31 09:19:36] ℹ️ Checking SSH connectivity to 51.159.134.32...�[0m
�[0;31m[2025-08-31 09:19:46] ❌ ERROR: Cannot connect to 51.159.134.32 via SSH�[0m - Health checking logic

  • �[0;31m[2025-08-31 09:19:46] ERROR: Usage: deployment/scripts/deploy-release.sh [--skip-backup]�[0m - Configuration loading patterns

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions