alfred-ide/start.sh

29 lines
1.0 KiB
Bash
Raw Permalink Normal View History

#!/bin/bash
# Alfred IDE - Start Script
# Launches code-server (rebranded as Alfred IDE)
# CRITICAL: unset VSCODE_IPC_HOOK_CLI or code-server detects VS Code and exits silently
unset VSCODE_IPC_HOOK_CLI
# Prevent file watcher from consuming all CPU when inotify fills up
export VSCODE_FILE_WATCHER_POLLING_INTERVAL=30000
export CHOKIDAR_USEPOLLING=0
PORT=8443
HOST=127.0.0.1
CODE_SERVER_BIN=/home/gositeme/.local/bin/code-server
# If Alfred IDE is already bound on the expected port, do not spawn a duplicate.
EXISTING_PID=$(ss -ltnp 2>/dev/null | awk -v addr="$HOST:$PORT" '$4 == addr { if (match($0, /pid=([0-9]+)/, m)) print m[1] }' | head -n 1)
if [[ -n "$EXISTING_PID" ]] && ps -p "$EXISTING_PID" -o args= 2>/dev/null | grep -q 'code-server'; then
echo "Alfred IDE already running on ${HOST}:${PORT} (pid ${EXISTING_PID})"
exit 0
fi
exec nice -n 15 ionice -c 3 /home/gositeme/.local/bin/code-server \
--bind-addr ${HOST}:${PORT} \
--disable-telemetry \
--disable-update-check \
--user-data-dir /home/gositeme/.local/share/code-server \
/home/gositeme