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
This commit is contained in:
2026-02-01 20:12:56 +01:00
parent 5deb0b0754
commit 1050b96d2a
3 changed files with 90 additions and 7 deletions

View File

@@ -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

34
docs/install-service.sh Executable file
View File

@@ -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"

49
docs/start-proxy.sh Executable file
View File

@@ -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 "$@"