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>
This commit is contained in:
Docker Config Backup
2025-07-29 14:27:28 +02:00
parent 58eb8c169b
commit 8ed2967f6f
7 changed files with 211 additions and 2 deletions

44
ecosystem.config.js Normal file
View File

@@ -0,0 +1,44 @@
module.exports = {
apps: [
{
name: 'timeshift-auto-commit',
script: './watch-and-commit.js',
cwd: '/home/klas/timeshift',
watch: false, // We don't want PM2 to restart on file changes since we're watching files ourselves
autorestart: true,
max_restarts: 10,
min_uptime: '10s',
restart_delay: 5000,
env: {
NODE_ENV: 'development',
PWD: '/home/klas/timeshift'
},
log_file: '/home/klas/timeshift/logs/auto-commit.log',
out_file: '/home/klas/timeshift/logs/auto-commit.out.log',
error_file: '/home/klas/timeshift/logs/auto-commit.error.log',
log_date_format: 'YYYY-MM-DD HH:mm:ss Z',
merge_logs: true,
max_memory_restart: '200M'
},
{
name: 'timeshift-dev',
script: 'npm',
args: 'run dev',
cwd: '/home/klas/timeshift',
watch: false,
autorestart: true,
max_restarts: 5,
min_uptime: '30s',
restart_delay: 10000,
env: {
NODE_ENV: 'development',
PORT: 3000
},
log_file: '/home/klas/timeshift/logs/dev-server.log',
out_file: '/home/klas/timeshift/logs/dev-server.out.log',
error_file: '/home/klas/timeshift/logs/dev-server.error.log',
log_date_format: 'YYYY-MM-DD HH:mm:ss Z',
merge_logs: true
}
]
};

View File

@@ -0,0 +1,2 @@
2025-07-29 14:27:23 +02:00: (node:489145) [DEP0060] DeprecationWarning: The `util._extend` API is deprecated. Please use Object.assign() instead.
2025-07-29 14:27:23 +02:00: (Use `node --trace-deprecation ...` to show where the warning was created)

22
logs/auto-commit.log Normal file
View File

@@ -0,0 +1,22 @@
2025-07-29 14:27:23 +02:00: 🚀 Timeshift Auto-Commit Watcher Started
2025-07-29 14:27:23 +02:00: ==========================================
2025-07-29 14:27:23 +02:00: 📅 Start time: 2025-07-29T12:27:23.269Z
2025-07-29 14:27:23 +02:00: 📁 Watching directories: components, app, lib, styles
2025-07-29 14:27:23 +02:00: 📄 File extensions: .tsx, .ts, .js, .jsx, .css, .scss, .json
2025-07-29 14:27:23 +02:00: ⏱️ Commit delay: 30s
2025-07-29 14:27:23 +02:00: 🚦 Max commits per hour: 10
2025-07-29 14:27:23 +02:00: 🔧 Process ID: 489145
2025-07-29 14:27:23 +02:00: ==========================================
2025-07-29 14:27:23 +02:00: 👀 Watching: /home/klas/timeshift/components
2025-07-29 14:27:23 +02:00: 👀 Watching: /home/klas/timeshift/app
2025-07-29 14:27:23 +02:00: 👀 Watching: /home/klas/timeshift/lib
2025-07-29 14:27:23 +02:00: ⚠️ Directory not found: /home/klas/timeshift/styles
2025-07-29 14:27:23 +02:00: 🚀 Auto-commit system ready! Press Ctrl+C to stop.
2025-07-29 14:27:23 +02:00: 📋 Commands available:
2025-07-29 14:27:23 +02:00: ./auto-commit.sh commit [message]
2025-07-29 14:27:23 +02:00: ./auto-commit.sh restore-point [description]
2025-07-29 14:27:23 +02:00: ./auto-commit.sh list
2025-07-29 14:27:23 +02:00: ./auto-commit.sh cleanup
2025-07-29 14:27:23 +02:00: (node:489145) [DEP0060] DeprecationWarning: The `util._extend` API is deprecated. Please use Object.assign() instead.
2025-07-29 14:27:23 +02:00: (Use `node --trace-deprecation ...` to show where the warning was created)
2025-07-29 14:27:28 +02:00: 🔖 Creating restore point...

20
logs/auto-commit.out.log Normal file
View File

@@ -0,0 +1,20 @@
2025-07-29 14:27:23 +02:00: 🚀 Timeshift Auto-Commit Watcher Started
2025-07-29 14:27:23 +02:00: ==========================================
2025-07-29 14:27:23 +02:00: 📅 Start time: 2025-07-29T12:27:23.269Z
2025-07-29 14:27:23 +02:00: 📁 Watching directories: components, app, lib, styles
2025-07-29 14:27:23 +02:00: 📄 File extensions: .tsx, .ts, .js, .jsx, .css, .scss, .json
2025-07-29 14:27:23 +02:00: ⏱️ Commit delay: 30s
2025-07-29 14:27:23 +02:00: 🚦 Max commits per hour: 10
2025-07-29 14:27:23 +02:00: 🔧 Process ID: 489145
2025-07-29 14:27:23 +02:00: ==========================================
2025-07-29 14:27:23 +02:00: 👀 Watching: /home/klas/timeshift/components
2025-07-29 14:27:23 +02:00: 👀 Watching: /home/klas/timeshift/app
2025-07-29 14:27:23 +02:00: 👀 Watching: /home/klas/timeshift/lib
2025-07-29 14:27:23 +02:00: ⚠️ Directory not found: /home/klas/timeshift/styles
2025-07-29 14:27:23 +02:00: 🚀 Auto-commit system ready! Press Ctrl+C to stop.
2025-07-29 14:27:23 +02:00: 📋 Commands available:
2025-07-29 14:27:23 +02:00: ./auto-commit.sh commit [message]
2025-07-29 14:27:23 +02:00: ./auto-commit.sh restore-point [description]
2025-07-29 14:27:23 +02:00: ./auto-commit.sh list
2025-07-29 14:27:23 +02:00: ./auto-commit.sh cleanup
2025-07-29 14:27:28 +02:00: 🔖 Creating restore point...

View File

@@ -10,7 +10,17 @@
"auto-commit": "./auto-commit.sh",
"watch-commit": "node watch-and-commit.js",
"save": "./auto-commit.sh commit",
"restore-point": "./auto-commit.sh restore-point"
"restore-point": "./auto-commit.sh restore-point",
"pm2:start": "pm2 start ecosystem.config.js",
"pm2:stop": "pm2 stop ecosystem.config.js",
"pm2:restart": "pm2 restart ecosystem.config.js",
"pm2:delete": "pm2 delete ecosystem.config.js",
"pm2:logs": "pm2 logs timeshift-auto-commit",
"pm2:status": "pm2 status",
"pm2:monit": "pm2 monit",
"services:start": "pm2 start ecosystem.config.js --only timeshift-auto-commit",
"services:stop": "pm2 stop timeshift-auto-commit",
"services:logs": "pm2 logs timeshift-auto-commit --lines 50"
},
"dependencies": {
"@radix-ui/react-dialog": "^1.1.14",

103
start-services.sh Executable file
View File

@@ -0,0 +1,103 @@
#!/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!"

View File

@@ -19,16 +19,24 @@ class AutoCommitWatcher {
this.commitTimeout = null;
this.commitsThisHour = 0;
this.lastCommitTime = 0;
this.startTime = new Date();
// Reset commit counter every hour
setInterval(() => {
this.commitsThisHour = 0;
console.log('🔄 Hourly reset: Commit counter reset to 0');
}, 3600000);
console.log('🔍 Auto-commit watcher started');
// Log startup info
console.log('🚀 Timeshift Auto-Commit Watcher Started');
console.log('==========================================');
console.log(`📅 Start time: ${this.startTime.toISOString()}`);
console.log(`📁 Watching directories: ${WATCH_DIRS.join(', ')}`);
console.log(`📄 File extensions: ${WATCH_EXTENSIONS.join(', ')}`);
console.log(`⏱️ Commit delay: ${COMMIT_DELAY/1000}s`);
console.log(`🚦 Max commits per hour: ${MAX_COMMITS_PER_HOUR}`);
console.log(`🔧 Process ID: ${process.pid}`);
console.log('==========================================');
}
start() {