From 1050b96d2ab00cd7bfc0f2e77d4c573e04a550e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torbj=C3=B8rn=20Lindahl?= Date: Sun, 1 Feb 2026 20:12:56 +0100 Subject: [PATCH] fix: make systemd service portable across machines - Add start-proxy.sh wrapper that handles nvm/fnm/volta/asdf - Add install-service.sh for one-command installation - Remove hardcoded node version paths from service file --- docs/antigravity-claude-proxy.service | 14 ++++---- docs/install-service.sh | 34 +++++++++++++++++++ docs/start-proxy.sh | 49 +++++++++++++++++++++++++++ 3 files changed, 90 insertions(+), 7 deletions(-) create mode 100755 docs/install-service.sh create mode 100755 docs/start-proxy.sh diff --git a/docs/antigravity-claude-proxy.service b/docs/antigravity-claude-proxy.service index e990690..c77ca51 100644 --- a/docs/antigravity-claude-proxy.service +++ b/docs/antigravity-claude-proxy.service @@ -2,9 +2,10 @@ # # Installation: # 1. Copy this file to ~/.config/systemd/user/antigravity-claude-proxy.service -# 2. Edit the paths below to match your system (especially if using nvm) -# 3. Run: systemctl --user daemon-reload -# 4. Run: systemctl --user enable --now antigravity-claude-proxy +# 2. Copy start-proxy.sh to a permanent location (e.g., ~/.local/bin/) +# 3. Update PROXY_SCRIPT below to point to start-proxy.sh +# 4. Run: systemctl --user daemon-reload +# 5. Run: systemctl --user enable --now antigravity-claude-proxy # # Management: # systemctl --user status antigravity-claude-proxy @@ -20,10 +21,9 @@ After=network.target Type=simple # Customize the port as needed Environment=PORT=3001 -# Update PATH to include your node binary location (check with: which node) -Environment=PATH=%h/.nvm/versions/node/v22.14.0/bin:/usr/local/bin:/usr/bin:/bin -# Update this path to match your antigravity-claude-proxy location (check with: which antigravity-claude-proxy) -ExecStart=%h/.nvm/versions/node/v22.14.0/bin/antigravity-claude-proxy start +# Path to the wrapper script - update this to match your installation +# The wrapper script handles nvm/fnm/volta/asdf automatically +ExecStart=%h/.local/bin/start-proxy.sh start Restart=on-failure RestartSec=5 diff --git a/docs/install-service.sh b/docs/install-service.sh new file mode 100755 index 0000000..4406e88 --- /dev/null +++ b/docs/install-service.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Install antigravity-claude-proxy as a systemd user service +# Run from anywhere - automatically detects paths + +set -e + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +LOCAL_BIN="$HOME/.local/bin" +SYSTEMD_USER_DIR="$HOME/.config/systemd/user" + +echo "Installing antigravity-claude-proxy systemd service..." + +# Create directories if needed +mkdir -p "$LOCAL_BIN" +mkdir -p "$SYSTEMD_USER_DIR" + +# Copy wrapper script +cp "$SCRIPT_DIR/start-proxy.sh" "$LOCAL_BIN/" +chmod +x "$LOCAL_BIN/start-proxy.sh" +echo " Installed: $LOCAL_BIN/start-proxy.sh" + +# Copy service file +cp "$SCRIPT_DIR/antigravity-claude-proxy.service" "$SYSTEMD_USER_DIR/" +echo " Installed: $SYSTEMD_USER_DIR/antigravity-claude-proxy.service" + +# Reload systemd +systemctl --user daemon-reload +echo " Reloaded systemd user daemon" + +echo "" +echo "Installation complete. Commands:" +echo " systemctl --user enable --now antigravity-claude-proxy # Start and enable on boot" +echo " systemctl --user status antigravity-claude-proxy # Check status" +echo " journalctl --user -u antigravity-claude-proxy -f # View logs" diff --git a/docs/start-proxy.sh b/docs/start-proxy.sh new file mode 100755 index 0000000..ed75474 --- /dev/null +++ b/docs/start-proxy.sh @@ -0,0 +1,49 @@ +#!/bin/bash +# Wrapper script for antigravity-claude-proxy that handles various Node.js version managers +# Used by the systemd service to ensure node is available in PATH + +set -e + +# Try nvm +if [ -z "$NVM_DIR" ]; then + export NVM_DIR="$HOME/.nvm" +fi +if [ -s "$NVM_DIR/nvm.sh" ]; then + source "$NVM_DIR/nvm.sh" +fi + +# Try fnm +if command -v fnm &> /dev/null; then + eval "$(fnm env)" +elif [ -d "$HOME/.fnm" ]; then + export PATH="$HOME/.fnm:$PATH" + eval "$(fnm env 2>/dev/null)" || true +fi + +# Try volta +if [ -d "$HOME/.volta" ]; then + export VOLTA_HOME="$HOME/.volta" + export PATH="$VOLTA_HOME/bin:$PATH" +fi + +# Try asdf +if [ -s "$HOME/.asdf/asdf.sh" ]; then + source "$HOME/.asdf/asdf.sh" +fi + +# Verify node is available +if ! command -v node &> /dev/null; then + echo "Error: node not found in PATH after sourcing version managers" >&2 + echo "PATH: $PATH" >&2 + exit 1 +fi + +# Verify antigravity-claude-proxy is available +if ! command -v antigravity-claude-proxy &> /dev/null; then + echo "Error: antigravity-claude-proxy not found in PATH" >&2 + echo "Install with: npm install -g antigravity-claude-proxy" >&2 + echo "PATH: $PATH" >&2 + exit 1 +fi + +exec antigravity-claude-proxy "$@"