- Added detailed error logging to detect snap node compatibility issues - When Pi process exits with code 1, log helpful diagnostic info including node path - Add hint to check for snap node and reinstall via apt/nvm - Create SNAP_NODE_COMPATIBILITY.md with full troubleshooting guide - Document root cause: snap node has file descriptor incompatibility with Bun.spawn stdin pipes - Provide clear installation instructions for NodeSource and nvm alternatives
58 lines
1.5 KiB
Bash
Executable File
58 lines
1.5 KiB
Bash
Executable File
#!/bin/bash
|
|
# Officer PTY Sidecar — systemd service setup
|
|
# Creates and enables a systemd service for the terminal PTY sidecar.
|
|
# Usage: bash scripts/setup-pty-sidecar.sh
|
|
|
|
set -euo pipefail
|
|
|
|
GREEN='\033[0;32m'
|
|
YELLOW='\033[1;33m'
|
|
NC='\033[0m'
|
|
|
|
ok() { echo -e " ${GREEN}✓${NC} $1"; }
|
|
warn() { echo -e " ${YELLOW}!${NC} $1"; }
|
|
skip() { echo -e " - $1 (already set up)"; }
|
|
|
|
SERVICE_NAME="officer-pty-sidecar"
|
|
SERVICE_FILE="/etc/systemd/system/${SERVICE_NAME}.service"
|
|
SERVICE_USER="$(whoami)"
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
|
|
NODE_BIN="$(which node)"
|
|
|
|
echo ""
|
|
echo "── PTY Sidecar (systemd service) ──"
|
|
|
|
if systemctl is-active --quiet "$SERVICE_NAME" 2>/dev/null; then
|
|
skip "$SERVICE_NAME service already running"
|
|
echo " Use 'bun run restart:sidecar' to restart"
|
|
exit 0
|
|
fi
|
|
|
|
sudo tee "$SERVICE_FILE" > /dev/null << EOF
|
|
[Unit]
|
|
Description=Officer PTY Sidecar
|
|
After=network.target
|
|
|
|
[Service]
|
|
Type=simple
|
|
User=$SERVICE_USER
|
|
WorkingDirectory=$PROJECT_DIR
|
|
Environment=TERMINAL_PTY_PORT=5338
|
|
ExecStart=$NODE_BIN $PROJECT_DIR/src/servers/api/terminal/pty-sidecar.mjs
|
|
Restart=on-failure
|
|
RestartSec=3
|
|
|
|
[Install]
|
|
WantedBy=multi-user.target
|
|
EOF
|
|
|
|
sudo systemctl daemon-reload
|
|
sudo systemctl enable --now "$SERVICE_NAME"
|
|
|
|
if systemctl is-active --quiet "$SERVICE_NAME"; then
|
|
ok "$SERVICE_NAME service installed and running"
|
|
else
|
|
warn "$SERVICE_NAME service failed to start — check 'journalctl -u $SERVICE_NAME'"
|
|
fi
|