diff --git a/CHANGELOG.md b/CHANGELOG.md index b5bc041..9711540 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,21 @@ The format is based on [Keep a Changelog][keepachangelog] and adheres to [Semant ### Deprecated ### Fixed +## [0.63.0] - 2025-11-10 + +### Added +- Added a new `kill` command to the Makefile for forcefully shutting down all development processes. +- Introduced a new `stop` command in the Makefile for graceful shutdown of development processes. + +### Changed +- The `kill` command now performs a graceful shutdown attempt followed by a force kill of any lingering processes and verifies that development ports are free. + +### Deprecated + +### Removed + +### Fixed +\n ## [0.62.0] - 2025-11-10 ### Added diff --git a/Makefile b/Makefile index 389194b..e05452f 100644 --- a/Makefile +++ b/Makefile @@ -21,7 +21,7 @@ test-e2e: .PHONY: build clean test run-node run-node2 run-node3 run-example deps tidy fmt vet lint clear-ports install-hooks kill -VERSION := 0.62.0 +VERSION := 0.63.0 COMMIT ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo unknown) DATE ?= $(shell date -u +%Y-%m-%dT%H:%M:%SZ) LDFLAGS := -X 'main.version=$(VERSION)' -X 'main.commit=$(COMMIT)' -X 'main.date=$(DATE)' @@ -87,8 +87,11 @@ run-gateway: dev: build @./bin/dbn dev up -# Kill all processes using dbn dev down +# Kill all processes (graceful shutdown + force kill stray processes) kill: + @bash scripts/dev-kill-all.sh + +stop: @./bin/dbn dev down # Help diff --git a/scripts/dev-kill-all.sh b/scripts/dev-kill-all.sh new file mode 100755 index 0000000..38d8386 --- /dev/null +++ b/scripts/dev-kill-all.sh @@ -0,0 +1,69 @@ +#!/bin/bash +set -euo pipefail + +ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" +BIN_DBN="$ROOT_DIR/bin/dbn" + +# First, try graceful shutdown via dbn dev down +if [[ -x "$BIN_DBN" ]]; then + echo "Attempting graceful shutdown via dbn dev down..." + "$BIN_DBN" dev down || true + sleep 1 +fi + +# Clean up PID files +PIDS_DIR="$HOME/.debros/.pids" +if [[ -d "$PIDS_DIR" ]]; then + echo "Removing stale PID files..." + rm -f "$PIDS_DIR"/*.pid || true +fi + +# Force kill any lingering processes +echo "Force killing any remaining dev processes..." + +declare -a PATTERNS=( + "ipfs daemon" + "ipfs-cluster-service daemon" + "rqlited" + "olric-server" + "anyone-client" + "bin/node" + "bin/gateway" +) + +killed_count=0 +for pattern in "${PATTERNS[@]}"; do + count=$(pgrep -f "$pattern" | wc -l) + if [[ $count -gt 0 ]]; then + pkill -f "$pattern" || true + echo "✓ Killed $count process(es) matching: $pattern" + killed_count=$((killed_count + count)) + fi +done + +if [[ $killed_count -eq 0 ]]; then + echo "✓ No lingering dev processes found" +else + echo "✓ Terminated $killed_count process(es) total" + sleep 1 +fi + +# Verify ports are free +echo "" +echo "Verifying ports are now available..." +PORTS=(4001 4501 4502 4503 5001 5002 5003 6001 7001 7002 7003 9094 9104 9114 3320 3322 9050) +unavailable=() + +for port in "${PORTS[@]}"; do + if lsof -nP -iTCP:"$port" -sTCP:LISTEN >/dev/null 2>&1; then + unavailable+=("$port") + fi +done + +if [[ ${#unavailable[@]} -eq 0 ]]; then + echo "✓ All required ports are free" +else + echo "⚠️ WARNING: These ports are still in use: ${unavailable[*]}" + echo "Use 'lsof -nP -i :PORT' to identify the processes" +fi +