Skip to content

Give Lima's autostart graceful shutdown time to finish - #184

Closed
samestep wants to merge 1 commit into
mainfrom
lima-autostart-exit-timeout
Closed

Give Lima's autostart graceful shutdown time to finish#184
samestep wants to merge 1 commit into
mainfrom
lima-autostart-exit-timeout

Conversation

@samestep

Copy link
Copy Markdown
Owner

No description provided.

On SIGTERM, Lima's hostagent gracefully powers off the guest and waits up
to 30s for it to halt (pkg/driver/vz/vz_driver_darwin.go). But its autostart
plists set no ExitTimeOut, so launchd's 5s default SIGKILLs the hostagent
when the Mac shuts down --- force-killing the guest mid-flush, which corrupts
Git repos and drops recent writes.

Patch the embedded LaunchAgent/LaunchDaemon plist templates to set
ExitTimeOut=60 (>= the driver's 30s stop timeout) so the graceful stop can
complete during host shutdown.

To try it out:

    # 1. Rebuild so the new limactl is on PATH:
    home-manager switch --flake ~/github/samestep/env#samueles

    # 2. Regenerate the installed plist (it does not update itself):
    limactl autostart disable sandbox-arm64 && limactl autostart enable sandbox-arm64

    # 3. Confirm it took (expect: exit timeout = 60):
    launchctl print gui/$(id -u)/io.lima-vm.autostart.sandbox-arm64 | grep -i 'exit timeout'

    # 4. After the next "Shut Down...", boot back up and, inside the guest, look
    #    for a full shutdown sequence (Stopping.../Unmounted/Power-Off) that was
    #    previously absent --- its span will often exceed the old 5s window:
    journalctl -b -1 -o short-precise | tail -30

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@samestep

Copy link
Copy Markdown
Owner Author

Superceded by #193.

@samestep samestep closed this Jul 20, 2026
@samestep
samestep deleted the lima-autostart-exit-timeout branch July 20, 2026 12:27
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.

1 participant