feat(autostart): add --keep-alive flag to limactl autostart enable#5086
Open
resker wants to merge 5 commits into
Open
feat(autostart): add --keep-alive flag to limactl autostart enable#5086resker wants to merge 5 commits into
resker wants to merge 5 commits into
Conversation
Adds `limactl autostart enable --condition=boot` to register a Lima instance
as a system-level LaunchDaemon. The VM starts at boot without requiring a user
login session, enabling headless macOS server deployments.
Also unifies the existing start-at-login functionality under the new
`limactl autostart` command and deprecates `limactl start-at-login`.
- pkg/autostart/launchd: add DaemonManager, plist template, and helpers
- pkg/autostart/managers.go: add extraTemplateVars field
- pkg/autostart/managers_darwin.go: DaemonManager constructor
- pkg/autostart/managers_{linux,others}.go: unsupported stubs
- cmd/limactl/autostart.go: cross-platform autostart command group
- cmd/limactl/autostart_darwin.go: login → LaunchAgent, boot → LaunchDaemon
- cmd/limactl/autostart_others.go: login only, boot returns unsupported error
- cmd/limactl/start-at-login.go: marked deprecated
- website/content/en/docs/usage/autostart.md: new documentation page
Signed-off-by: Robert Esker <resker@gmail.com>
Add --keep-alive (default: true) to both LaunchAgent and LaunchDaemon plist templates. When enabled, launchd restarts the Lima host agent automatically if it exits unexpectedly, preventing instances from remaining in a Broken state until the next login or reboot. The flag is accepted on all platforms; on Linux it is a no-op since systemd restart behavior is configured separately in the unit file. Closes: lima-vm#4992 Signed-off-by: Robert Esker <resker@gmail.com>
Signed-off-by: Robert Esker <resker@gmail.com>
6a6b3ee to
1c43fab
Compare
Without whitespace trimming, the {{if}}...{{end}} block left a blank
line in the rendered plist when KeepAlive=false, breaking unit tests.
Signed-off-by: Robert Esker <resker@gmail.com>
Author
|
@AkihiroSuda - fyi, also submitted a follow-up PR #5086 |
This was referenced Jun 6, 2026
The systemd unit uses Restart=on-failure unconditionally, so --keep-alive is always active on Linux regardless of the flag value. Signed-off-by: Robert Esker <resker@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Depends on #4984.
Summary
--keep-alive(default:true) tolimactl autostart enablefor both LaunchAgent and LaunchDaemon plist templatesBrokenstate until the next login or rebootTesting
--keep-alive=true--keep-alive=falseCloses #4992
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license and I have signed off all commits per the DCO.