brew services start colima
. You can skip the following work-around.
- Create an executable script to run in foreground and manage colima:
cat <<-EOF | sudo tee /usr/local/bin/colima-start-fg
#!/bin/bash
export PATH="/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
function shutdown() {
colima stop
exit 0
}
trap shutdown SIGTERM
trap shutdown SIGINT
# wait until colima is running
while true; do
colima status &>/dev/null
if [[ \$? -eq 0 ]]; then
break;
fi
colima start
sleep 5
done
tail -f /dev/null &
wait \$!
EOF
sudo chmod +x /usr/local/bin/colima-start-fg
- Create a launchd agent to run colima automatically:
cat > $HOME/Library/LaunchAgents/com.github.abiosoft.colima.plist <<-EOF
<?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>com.github.abiosoft.colima</string>
<key>Program</key>
<string>/usr/local/bin/colima-start-fg</string>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<false/>
</dict>
</plist>
EOF
launchctl load -w $HOME/Library/LaunchAgents/com.github.abiosoft.colima.plist
Speaking for my company as a whole - "sometimes" - but typically for me, yes. We have been advised to start it with homebrew rather than just
colima start
, so we're trying to work around that requirement. But something you said made something click: if you start it with homebrew, it is actually starting, but it's not ready right away.We have had intermittent reports of people saying starting with homebrew made colima start, and the inconsistency brought us to the understanding that starting with homebrew was pretty much just acting like
systemd enable
to make sure it comes back up automatically. I think the perception of a problem is caused by the whole "if I can't see it happening, it isn't" misconception because the twitch response tocolima status
returning that it isn't running has always been to runcolima start
, so we never see that if we do nothing, it will come up.So now my task is to figure out how to poll
colima status
until it reports that it's up before moving on so it continues to work in our scripts. I don't know much about launchd, but I'm pretty sure I can do this in a shell script somehow. If you can think of an easy way though, would love your input. Thank you for the response btw!