Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Justfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Justfile

mod goose2 'ui/goose2'

# list all tasks
default:
@just --list
Expand Down
34 changes: 28 additions & 6 deletions ui/goose2/justfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Derive a stable port from the working directory so the same worktree
# always gets the same port.
vite_port := `python3 -c "import hashlib,os; h=int(hashlib.sha256(os.getcwd().encode()).hexdigest(),16); print(10000 + h % 55000)"`

# Default recipe
default:
@just --list
Expand Down Expand Up @@ -74,11 +78,7 @@ dev:
#!/usr/bin/env bash
set -euo pipefail

# Derive a stable port from the working directory so the same worktree
# always gets the same port. This avoids changing TAURI_CONFIG between
# runs, which would invalidate Cargo's build cache and trigger a full
# Rust rebuild every time.
VITE_PORT=$(python3 -c "import hashlib,os; h=int(hashlib.sha256(os.getcwd().encode()).hexdigest(),16); print(10000 + h % 55000)")
VITE_PORT={{ vite_port }}
export VITE_PORT
PROJECT_DIR=$(pwd)
TAURI_CONFIG="{\"build\":{\"devUrl\":\"http://localhost:${VITE_PORT}\",\"beforeDevCommand\":{\"script\":\"cd ${PROJECT_DIR} && exec pnpm exec vite --port ${VITE_PORT} --strictPort\",\"cwd\":\".\",\"wait\":false}}}"
Expand Down Expand Up @@ -108,7 +108,7 @@ dev-debug:
#!/usr/bin/env bash
set -euo pipefail

VITE_PORT=$(python3 -c "import hashlib,os; h=int(hashlib.sha256(os.getcwd().encode()).hexdigest(),16); print(10000 + h % 55000)")
VITE_PORT={{ vite_port }}
export VITE_PORT
EXTRA_CONFIG="--config {\"build\":{\"devUrl\":\"http://localhost:${VITE_PORT}\",\"beforeDevCommand\":{\"script\":\"exec ./node_modules/.bin/vite --port ${VITE_PORT} --strictPort\",\"cwd\":\"..\",\"wait\":false}}}"

Expand Down Expand Up @@ -136,6 +136,28 @@ dev-debug:
dev-frontend:
pnpm dev

# Kill the dev process (if running)
kill:
#!/usr/bin/env bash
set -euo pipefail

VITE_PORT={{ vite_port }}
PID=$(lsof -ti :"$VITE_PORT" 2>/dev/null | head -1) || true
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Select the listening PID on the Vite port

Using lsof -ti :"$VITE_PORT" | head -1 can pick any process that has a socket associated with that port (including clients connected to Vite), not necessarily the Node listener. In that case PROC_NAME is often not node, so the recipe exits with “refusing to kill” even though the dev server is still running. This is most likely when the app/browser is connected to the dev server. Filter for the listening socket (for example with TCP LISTEN constraints) before choosing a PID.

Useful? React with 👍 / 👎.


if [[ -z "$PID" ]]; then
echo "No process found on port $VITE_PORT"
exit 0
fi

PROC_NAME=$(ps -p "$PID" -o comm= 2>/dev/null) || true
if [[ "$PROC_NAME" != "node" ]]; then
echo "Process on port $VITE_PORT is '$PROC_NAME', not 'node' — refusing to kill"
exit 1
fi

echo "Killing node (PID $PID) on port $VITE_PORT"
kill -9 "$PID"

# ── Utilities ────────────────────────────────────────────────

# Clean build artifacts
Expand Down
Loading