- Add cleanup-chromium.sh script for manual zombie process cleanup - Add docker-entrypoint.sh with signal handlers for graceful shutdown - Add lib/process-cleanup.ts for automatic cleanup on app termination - Enhanced forceCleanup() method in tradingview-automation.ts: - Individual page closing before browser termination - Force kill remaining processes with SIGKILL - Reset operation locks after cleanup - Improved browser launch args to prevent zombie processes: - Better crash reporter handling - Enhanced background process management - Removed problematic --single-process flag - Updated Dockerfile to use new entrypoint with cleanup handlers - Set DOCKER_ENV environment variable for container detection - Add proper signal handling (SIGINT, SIGTERM, SIGQUIT) - Automatic cleanup of temporary Puppeteer profiles Resolves zombie Chromium process accumulation issue
27 lines
952 B
Bash
Executable File
27 lines
952 B
Bash
Executable File
#!/bin/bash
|
|
|
|
# Cleanup script to kill zombie Chromium processes
|
|
# This should be run periodically or when the application shuts down
|
|
|
|
echo "🧹 Cleaning up zombie Chromium processes..."
|
|
|
|
# Kill all defunct chromium processes
|
|
pkill -f "chromium.*defunct" 2>/dev/null
|
|
|
|
# Kill any remaining chromium processes in the container
|
|
if [ -n "$DOCKER_ENV" ]; then
|
|
echo "Running in Docker environment, cleaning up container processes..."
|
|
# In Docker, we need to be more careful about process cleanup
|
|
ps aux | grep '[c]hromium' | grep -v grep | awk '{print $2}' | xargs -r kill -TERM 2>/dev/null
|
|
sleep 2
|
|
ps aux | grep '[c]hromium' | grep -v grep | awk '{print $2}' | xargs -r kill -KILL 2>/dev/null
|
|
else
|
|
echo "Running in host environment, cleaning up host processes..."
|
|
pkill -f "chromium" 2>/dev/null
|
|
fi
|
|
|
|
# Clean up any temporary puppeteer profiles
|
|
rm -rf /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null
|
|
|
|
echo "✅ Cleanup completed"
|