Files
tkb_timeshift/start-services.sh
Docker Config Backup 8ed2967f6f Save before creating restore point: Session start
Auto-saved at 2025-07-29 14:27:28

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-29 14:27:28 +02:00

103 lines
2.8 KiB
Bash
Executable File

#!/bin/bash
# Timeshift Project Services Startup Script
# This script starts the auto-commit watcher and development server using PM2
set -e
echo "🚀 Starting Timeshift Project Services"
echo "========================================"
# Function to check if PM2 is installed
check_pm2() {
if ! command -v pm2 &> /dev/null; then
echo "❌ PM2 is not installed. Please install it first:"
echo " npm install -g pm2"
exit 1
fi
echo "✅ PM2 is available"
}
# Function to start services
start_services() {
echo ""
echo "🔧 Starting services..."
# Stop any existing services first
pm2 delete timeshift-auto-commit 2>/dev/null || true
pm2 delete timeshift-dev 2>/dev/null || true
# Start the auto-commit watcher
echo "📁 Starting auto-commit watcher..."
pm2 start ecosystem.config.js --only timeshift-auto-commit
# Wait a moment for the service to start
sleep 2
echo ""
echo "✅ Services started successfully!"
echo ""
# Show status
pm2 status
echo ""
echo "📋 Service Management Commands:"
echo " npm run services:logs - View auto-commit logs"
echo " npm run services:stop - Stop auto-commit service"
echo " npm run pm2:status - Check all PM2 services"
echo " npm run pm2:monit - Open PM2 monitoring"
echo ""
echo "🌐 Development Server:"
echo " npm run dev - Start Next.js dev server manually"
echo " npm run pm2:start - Start both services with PM2"
echo ""
echo "💾 Manual Save Commands:"
echo " npm run save - Save changes immediately"
echo " npm run restore-point - Create a restore point"
echo ""
}
# Function to show logs
show_logs() {
echo "📋 Auto-commit service logs (last 20 lines):"
echo "============================================"
pm2 logs timeshift-auto-commit --lines 20 --nostream
}
# Main execution
case "$1" in
"logs")
show_logs
;;
"stop")
echo "🛑 Stopping auto-commit service..."
pm2 stop timeshift-auto-commit
echo "✅ Service stopped"
;;
"restart")
echo "🔄 Restarting auto-commit service..."
pm2 restart timeshift-auto-commit
echo "✅ Service restarted"
;;
"status")
pm2 status
;;
*)
check_pm2
start_services
# Option to show logs
echo "👀 Would you like to see the logs? (y/n)"
read -t 10 -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
show_logs
fi
;;
esac
echo ""
echo "🎯 Auto-commit watcher is now running in the background!"
echo "🔄 Your changes will be automatically saved every 30 seconds."
echo "🛡️ No more lost work when Claude restarts!"