Files
skywatch/update-server.sh
T
nmemmertandClaude Sonnet 4.6 0f93d16874 Add build-tool install step to update script
Ensures gcc/g++/python3 are present before npm install so
better-sqlite3 can compile its native binding on a fresh Ubuntu server.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-08-06 18:19:20 -04:00

53 lines
1.4 KiB
Bash

#!/bin/bash
# Quick update script for SkyWatch on remote server
# Run this on the server: bash update-server.sh
set -e
echo "🔄 Updating SkyWatch..."
cd /opt/resource-monitor
echo "📥 Pulling latest code..."
git pull origin main
echo "🔧 Ensuring build tools are present (needed for native modules)..."
if command -v apt-get &>/dev/null; then
apt-get install -y --no-install-recommends make gcc g++ python3 2>&1 | tail -5
elif command -v dnf &>/dev/null; then
dnf install -y make gcc gcc-c++ python3 2>&1 | tail -5
elif command -v yum &>/dev/null; then
yum install -y make gcc gcc-c++ python3 2>&1 | tail -5
fi
echo "📦 Installing dependencies..."
rm -rf node_modules
# Prefer deterministic installs with npm ci when lockfile is present.
if [ -f package-lock.json ]; then
if ! npm ci --omit=dev 2>&1 | tail -20; then
echo "npm ci failed, falling back to npm install..."
npm install --omit=dev 2>&1 | tail -20
fi
else
echo "No package-lock.json found, using npm install..."
npm install --omit=dev 2>&1 | tail -20
fi
echo "🔄 Restarting application..."
pm2 restart resource-monitor
echo "✅ Waiting for startup..."
sleep 3
echo "📋 Checking status..."
pm2 status resource-monitor
echo ""
echo "📊 Recent logs (checking for database migration):"
pm2 logs resource-monitor --lines 30 --nostream
echo ""
echo "✅ Update complete!"
echo "🌐 Check your dashboard at http://$(hostname -I | awk '{print $1}'):3001"