Skip to content

fix: exit GUI and mini mode when the server shuts down on SIGTERM - #270

Merged
ErikBjare merged 1 commit into
ActivityWatch:masterfrom
0xbrayo:fix/sigterm-shutdown
Sep 23, 2026
Merged

ErikBjare merged 1 commit into
ActivityWatch:masterfrom
0xbrayo:fix/sigterm-shutdown

Conversation

@0xbrayo

@0xbrayo 0xbrayo commented Sep 23, 2026

Copy link
Copy Markdown
Member

On SIGINT/SIGTERM (and SIGHUP on Unix), Rocket shuts the server down gracefully. Daemon mode then stops the modules and exits. GUI mode drops the launch handle, though, and mini mode ignores a clean shutdown. The process and its modules keep running without a server, and only the tray's Quit or SIGKILL ends them.

This watches the Rocket task in both modes. Once it finishes, they stop the modules and exit, with code 1 if the server failed.

GUI mode now also exits if the server fails. Before, it stayed open with a dead dashboard; mini and daemon mode already exited.

Testing

  • Mini mode under --testing with real modules, sending SIGTERM:
    • Before: the process was still running 15 s later.
    • After: it exits with code 0 after about 7 s (Rocket's shutdown grace period), and all modules are gone.
  • GUI mode was compiled and linted but not launched: on macOS its single-instance check hands off to an already-running installed instance.
  • cargo fmt --check and cargo clippy --all-targets -D warnings pass.

Rocket handles SIGINT/SIGTERM (and SIGHUP on Unix) by shutting the
server down gracefully. Daemon mode then stops the modules and exits,
but GUI mode dropped the launch handle and mini mode ignored a clean
shutdown, so the process and its modules kept running without a server.
Only the tray's Quit, or SIGKILL, ended them.

Watch the Rocket task in both modes: once it finishes, stop the modules
and exit, with code 1 if the server failed. In mini mode, SIGTERM now
exits with code 0 after about 7s (Rocket's shutdown grace period), and
all modules are gone; before, it was still running 15s later.
@greptile-apps

greptile-apps Bot commented Sep 23, 2026

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

The PR appears safe to merge; both changed runtime paths now pair server termination with module cleanup and the expected process status.

Summary

This PR aligns embedded-server shutdown handling across the desktop, mini, and daemon runtime modes.

  • Full GUI mode now watches the Rocket task, stops managed modules when it ends, and exits with a status reflecting success or failure.
  • Mini mode now treats clean Rocket shutdown as an explicit event, stops managed modules, and exits its event loop.
  • Server errors and task panics continue to produce non-zero process exits.

Diagram

sequenceDiagram
    participant Signal as SIGINT/SIGTERM/SIGHUP
    participant Rocket as Embedded Rocket server
    participant Runtime as GUI or mini runtime
    participant Manager as Module manager
    participant Process as Application process

    Signal->>Rocket: Request graceful shutdown
    Rocket-->>Runtime: Server task completes
    Runtime->>Manager: stop_modules()
    alt Clean server shutdown
        Runtime->>Process: Exit with status 0
    else Server error or task panic
        Runtime->>Process: Exit with status 1
    end
Loading

Reviews (1) · Last reviewed commit: "fix: exit GUI and mini mode when the ser..."

@ErikBjare
ErikBjare merged commit 1e85747 into ActivityWatch:master Sep 23, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants