Skip to content

YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context

fix(dev-vm): detect running VM by process; tart ip returns stale DHCP lease when stopped

Louis Beaumont76ebdd3184b4
diff --git a/scripts/dev-vm/run.sh b/scripts/dev-vm/run.sh
index 76c4952db..b0b7dbbc4 100755
--- a/scripts/dev-vm/run.sh
+++ b/scripts/dev-vm/run.sh
@@ -10,7 +10,8 @@
set -euo pipefail
VM_NAME="${VM_NAME:-screenpipe-dev}"
-if tart ip "$VM_NAME" >/dev/null 2>&1; then
+# note: `tart ip` returns a stale DHCP lease even when stopped; check the process
+if pgrep -f "tart run ${VM_NAME}" >/dev/null 2>&1; then
echo "$VM_NAME is already running (headless?). Stop it first: tart stop $VM_NAME" >&2
exit 1
fi
diff --git a/scripts/dev-vm/setup.sh b/scripts/dev-vm/setup.sh
index 3ab0d3cb0..24a8179c1 100755
--- a/scripts/dev-vm/setup.sh
+++ b/scripts/dev-vm/setup.sh
@@ -52,8 +52,8 @@ if ! tart list --quiet | grep -qx "$VM_NAME"; then
tart set "$VM_NAME" --cpu "$VM_CPU" --memory "$VM_MEM" --disk-size "$VM_DISK"
fi
-# 4. boot headless if not running
-if ! tart ip "$VM_NAME" >/dev/null 2>&1; then
+# 4. boot headless if not running (`tart ip` returns a stale lease when stopped; check the process)
+if ! pgrep -f "tart run ${VM_NAME}" >/dev/null 2>&1; then
log "booting $VM_NAME headless..."
nohup tart run "$VM_NAME" --no-graphics >/tmp/${VM_NAME}.log 2>&1 &
fi