From 13e1c6dd5cdbf8e47bd5c6645c4e33cc786d9021 Mon Sep 17 00:00:00 2001 From: grabowski Date: Mon, 27 Oct 2025 16:16:08 +0700 Subject: [PATCH] Fix systemd service to use uv with full path MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Updated service to use uv run with absolute path to avoid PATH issues in systemd environment. Service file changes: - ExecStart: Uses absolute path to uv (/home/berwn/.local/bin/uv) - Runs: uv run --no-project python rotary_phone_web.py - This ensures uv manages dependencies correctly Install script improvements: - Auto-detects uv location with 'which uv' - Falls back to $HOME/.local/bin/uv if not in PATH - Validates uv exists before proceeding - Substitutes actual uv path into service file - Shows detected uv path in output This fixes: ModuleNotFoundError: No module named 'waitress' Now uv properly manages the virtual environment and dependencies are available to the service. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- install_service.sh | 15 +++++++++++++++ wedding-phone.service | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/install_service.sh b/install_service.sh index 3bf609f..5778222 100644 --- a/install_service.sh +++ b/install_service.sh @@ -64,6 +64,19 @@ make sync echo -e "${GREEN}✓ Dependencies installed${NC}" echo "" +# Find uv location +UV_PATH=$(which uv) +if [ -z "$UV_PATH" ]; then + UV_PATH="$HOME/.local/bin/uv" + if [ ! -f "$UV_PATH" ]; then + echo -e "${RED}ERROR: Cannot find uv executable${NC}" + echo "Checked: $(which uv), $HOME/.local/bin/uv" + exit 1 + fi +fi + +echo -e "${GREEN}✓ Found uv at: $UV_PATH${NC}" + # Update the service file with the correct path echo "Configuring service file..." TEMP_SERVICE="/tmp/wedding-phone.service" @@ -74,11 +87,13 @@ cat "$SERVICE_FILE" | \ sed "s|User=berwn|User=$CURRENT_USER|g" | \ sed "s|Group=berwn|Group=$CURRENT_USER|g" | \ sed "s|/home/berwn/wedding-phone|$SCRIPT_DIR|g" | \ + sed "s|/home/berwn/.local/bin/uv|$UV_PATH|g" | \ sed "s|/home/berwn/.local/bin|$USER_HOME/.local/bin|g" \ > "$TEMP_SERVICE" echo -e "${GREEN}✓ Service file configured for user: $CURRENT_USER${NC}" echo -e "${GREEN}✓ Working directory: $SCRIPT_DIR${NC}" +echo -e "${GREEN}✓ UV path: $UV_PATH${NC}" echo "" # Install the service diff --git a/wedding-phone.service b/wedding-phone.service index 492b1b0..9924644 100644 --- a/wedding-phone.service +++ b/wedding-phone.service @@ -9,7 +9,7 @@ User=berwn Group=berwn WorkingDirectory=/home/berwn/wedding-phone Environment="PATH=/home/berwn/.local/bin:/usr/local/bin:/usr/bin:/bin" -ExecStart=/usr/bin/python3 rotary_phone_web.py +ExecStart=/home/berwn/.local/bin/uv run --no-project python rotary_phone_web.py Restart=always RestartSec=10