You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
autostart: Ensure instance is started/stopped by launchd or systemctl
If the instance isn’t launched by `launchd`, it won’t be stopped on log out.
This changes to use `launchctl` or `systemctl` to start/stop the instance if it’s registered to autostart.
## Affected sub commands:
- `limactl start`
- `limactl stop`
- `limactl restart`
- `limactl edit`
- `limactl shell`
## API changes
### `pkg/autostart`
- Introduced `AutoStartedIdentifier()`:
- If not empty, it indicates whether the instance was started by `launchd` or `systemd`.
- Added `RequestStart()`:
- Delegates the operation to `launchd` or `systemd`.
- Added `RequestStop()`:
- Delegates the operation to `launchd` or `systemd`.
### `pkg/autostart/launchd`
- Added `AutoStartedServiceName()`:
- Uses the XPC_SERVICE_NAME environment variable as the service name.
- Added `RequestStart()`:
- Uses `launchctl enable service-target` to avoid failing `bootstrap`.
- Uses `launchctl bootstrap domain-target plist-path`.
- Added `RequestStop()`:
- Uses `launchctl bootout service-target` if the instance is launched by `launchd`.
- Added `--progress` to the `limactl` option in `io.lima-vm.autostart.INSTANCE.plist`:
- Required to support `limactl start --progress`.
### `pkg/autostart/systemd`
- Added `AutoStartedServiceName()`:
- Uses `CurrentUnitName()` by `github.com/coreos/go-systemd/v22/util` as the service identifier.
- Added `RequestStart()`:
- Uses `systemctl --user start unit-name`.
- Added `RequestStop()`:
- Uses `systemctl --user stop unit-name` if the instance is launched by `systemd`.
- Added `--progress` to the `limactl` option in `[email protected]`:
- Required to support `limactl start --progress`.
### `pkg/hostagent`
- Add `AutoStartedIdentifier` to `Info`.
- If not empty, it indicates whether the instance was started by `launchd` or `systemd`.
### `pkg/instance`
- `StartWithPaths()`:
- Use `autostart.IsRegistered()` to check if the instance is registered to autostart.
- If `launchHostAgentForeground` is true, ignore autostart registration.
- If the instance is registered to autostart, use `autostart.RequestStart()` instead of launching HostAgent.
- `StopGracefully()`:
- Use `autostart.RequestStop()`.
- `Restart()`, `RestartForcibly()`:
- Use `autostart.IsRegistered()` to skip `networks.Reconcile()` if the instance is registered to autostart.
Signed-off-by: Norio Nomura <[email protected]>
0 commit comments