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
This change adds the `--foreground` flag to `limactl start`.
This flag:
- Launches `limactl hostagent` with `syscall.Exec`, which allows `limactl start --foreground` to be used in macOS's `launchd.plist`, making it possible to hide `limactl hostagent`.
- When launched from the terminal, it uses the terminal for standard output and standard error instead of the default `ha.std{out,err}.log` files. In this case, a message indicating that the default log files are not used is written to the log files.
- When launched from something other than the terminal, such as `launchd`, it uses the `ha.std{out,err}.log` files as before.
- Cannot be used on Windows.
The following are the updated steps to set up the Docker instance of Lima to start at login using launchd on macOS:
```bash
# Create the docker instance
limactl create template://docker --vm-type vz --rosetta --network vzNAT --tty=false
# Create the launchd plist
echo '<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>io.lima-vm.docker</string>
<key>ProgramArguments</key>
<array>
<string>'"$(which limactl)"'</string>
<string>start</string>
<string>--foreground</string>
<string>docker</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>StandardErrorPath</key>
<string>launchd.stderr.log</string>
<key>StandardOutPath</key>
<string>launchd.stdout.log</string>
<key>WorkingDirectory</key>
<string>'"$(limactl list docker --format '{{.Dir}}')"'</string>
</dict>
</plist>' > ~/Library/LaunchAgents/io.lima-vm.docker.plist
# Load the launchd plist and launchd will start the docker instance
launchctl load ~/Library/LaunchAgents/io.lima-vm.docker.plist
```
that changed from #2140:
- Changed to `limactl create` because it's no longer necessary to run `limactl start` before loading into `launchd`.
- Changed from `limactl hostagent` to `limactl start --foreground`.
- Changed `Standard{Error,Out}Path` to `launchd.std{err,out}.log`, so that only the output of `limactl start` is written.
Signed-off-by: Norio Nomura <norio.nomura@gmail.com>
Update cmd/limactl/start.go
Change `instance` to `hostagent`
Co-authored-by: Akihiro Suda <suda.kyoto@gmail.com>
Add `launchHostAgentForeground` to `start.Start()`
Avoid using `Context` to passing `launchHostAgentForeground`
Remove `start.DefaultLaunchHostAgentForeground`
startCommand.Flags().Bool("foreground", false, "run the hostagent in the foreground")
98
+
}
95
99
startCommand.Flags().Duration("timeout", start.DefaultWatchHostAgentEventsTimeout, "duration to wait for the instance to be running before timing out")
0 commit comments