Skip to content

[FEATURE] Implement Service Restart Logic #99

@Firstp1ck

Description

@Firstp1ck

Add logic for restarting services after package operations

Summary

Implement the missing service restart functionality in the PostSummary modal. Currently, pressing 's' only shows a toast message but doesn't actually restart the systemd services that are pending restart after package operations.

Files to modify

  • src/events/modals/common.rs (around line 295)

Expected behavior

When users press 's' in the PostSummary modal and there are services pending restart:

  1. Execute systemctl restart <service> for each service in the services_pending list
  2. Show appropriate success/error messages for each service restart attempt
  3. Handle partial failures gracefully (some services might fail while others succeed)
  4. Update the UI state to reflect that services have been restarted

Testing

  • cargo check passes
  • cargo clippy --all-targets --all-features -- -D warnings passes
  • cargo test -- --test-threads=1 passes
  • Test service restart with mock systemctl commands
  • Test error handling when systemctl is not available
  • Test partial failure scenarios (some services restart successfully, others fail)

Additional context

The implementation should integrate with systemd service management using the existing run_command infrastructure from src/logic/services/command.rs. Follow the pattern used in src/logic/services/systemd.rs for executing systemctl commands.

Key considerations:

  • Use systemctl restart <service> for each service in services_pending
  • Handle both success and failure cases gracefully
  • Consider running restarts asynchronously to avoid blocking the UI
  • Update the modal state after successful restarts
  • Add proper error messages and logging

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions