From 014b6325173405f6a3ebbd3d714393158615dddc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claude4=CE=9Elope?= Date: Sat, 28 Jun 2025 00:07:56 +0200 Subject: [PATCH] Add daemon management targets to Makefile MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add 'make run' target that installs and restarts daemon from home directory - Add 'make restart' target to stop and start daemon without install - Add 'make stop' target to safely stop running daemon - Add 'make status' target to check daemon status with PID verification - Fixes issue where daemon doesn't update after 'make install' - Ensures daemon runs from .venv/bin/ to avoid stale system-wide version - Includes process verification with ps command to confirm replacement 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- Makefile | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 57 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 551e29e..58cc7a6 100644 --- a/Makefile +++ b/Makefile @@ -1,13 +1,17 @@ # Makefile for MCP Browser # Created by AI for AI development -.PHONY: test install clean lint docs help +.PHONY: test install clean lint docs help run restart stop status help: @echo "MCP Browser Development Commands" @echo "================================" @echo "make test - Run all tests (unit + integration)" @echo "make install - Install package in development mode" + @echo "make run - Install and restart daemon from home directory" + @echo "make restart - Stop and restart daemon (without install)" + @echo "make stop - Stop running daemon" + @echo "make status - Show daemon status" @echo "make lint - Run code quality checks" @echo "make docs - Generate AI-friendly documentation" @echo "make clean - Remove build artifacts" @@ -45,4 +49,55 @@ format: black mcp_browser/ mcp_servers/ tests/ typecheck: - mypy mcp_browser/ --ignore-missing-imports \ No newline at end of file + mypy mcp_browser/ --ignore-missing-imports + +# Daemon management targets +status: + @echo "=== MCP Browser Daemon Status ===" + @if [ -f /tmp/mcp-browser-1004/mcp-browser.pid ]; then \ + pid=$$(cat /tmp/mcp-browser-1004/mcp-browser.pid); \ + echo "PID file exists: $$pid"; \ + if ps -p $$pid > /dev/null 2>&1; then \ + echo "✓ Daemon is running (PID: $$pid)"; \ + ps -fp $$pid; \ + else \ + echo "✗ Daemon not running (stale PID file)"; \ + fi; \ + else \ + echo "✗ No PID file found"; \ + fi + +stop: + @echo "=== Stopping MCP Browser Daemon ===" + @if [ -f /tmp/mcp-browser-1004/mcp-browser.pid ]; then \ + pid=$$(cat /tmp/mcp-browser-1004/mcp-browser.pid); \ + echo "Stopping daemon (PID: $$pid)..."; \ + if ps -p $$pid > /dev/null 2>&1; then \ + kill -TERM $$pid; \ + sleep 2; \ + if ps -p $$pid > /dev/null 2>&1; then \ + echo "Daemon still running, force killing..."; \ + kill -KILL $$pid; \ + fi; \ + echo "✓ Daemon stopped"; \ + else \ + echo "Daemon was not running"; \ + fi; \ + rm -f /tmp/mcp-browser-1004/mcp-browser.pid; \ + else \ + echo "No PID file found"; \ + fi + +restart: + @echo "=== Restarting MCP Browser Daemon ===" + $(MAKE) stop + @echo "Starting daemon from home directory..." + @cd /mnt/data/claude/claude && nohup /mnt/data/claude/claude/.venv/bin/mcp-browser-daemon > /dev/null 2>&1 & + @sleep 3 + @echo "Verifying daemon restart..." + $(MAKE) status + +run: + @echo "=== Installing and Running MCP Browser Daemon ===" + $(MAKE) install + $(MAKE) restart \ No newline at end of file