mirror of
https://github.com/RayLabsHQ/gitea-mirror.git
synced 2025-12-11 05:56:46 +03:00
feat: Improve cron job setup for automatic database cleanup with better error handling
This commit is contained in:
@@ -227,26 +227,28 @@ fi
|
|||||||
if command -v crontab >/dev/null 2>&1; then
|
if command -v crontab >/dev/null 2>&1; then
|
||||||
echo "Setting up automatic database cleanup cron jobs..."
|
echo "Setting up automatic database cleanup cron jobs..."
|
||||||
# Install cron if not already installed
|
# Install cron if not already installed
|
||||||
if ! command -v cron >/dev/null 2>&1; then
|
if ! command -v crond >/dev/null 2>&1; then
|
||||||
echo "Installing cron..."
|
echo "Installing cron..."
|
||||||
apt-get update && apt-get install -y cron
|
apk add --no-cache dcron
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Install the cron job
|
# Try to install the cron job, but don't fail if it doesn't work
|
||||||
crontab /app/data/cron/cleanup-cron
|
if crontab /app/data/cron/cleanup-cron 2>/dev/null; then
|
||||||
|
echo "✅ Cron job installed successfully"
|
||||||
|
|
||||||
# Start cron service
|
# Start cron service (Alpine uses crond)
|
||||||
if command -v service >/dev/null 2>&1; then
|
if command -v crond >/dev/null 2>&1; then
|
||||||
service cron start
|
crond -b
|
||||||
echo "Cron service started"
|
echo "✅ Cron daemon started"
|
||||||
elif command -v cron >/dev/null 2>&1; then
|
else
|
||||||
cron
|
echo "⚠️ Warning: Could not start cron service. Automatic database cleanup will not run."
|
||||||
echo "Cron daemon started"
|
fi
|
||||||
else
|
else
|
||||||
echo "Warning: Could not start cron service. Automatic database cleanup will not run."
|
echo "⚠️ Warning: Could not install cron job (permission issue). Automatic database cleanup will not be set up."
|
||||||
|
echo "Consider setting up external scheduled tasks to run cleanup scripts."
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "Warning: crontab command not found. Automatic database cleanup will not be set up."
|
echo "⚠️ Warning: crontab command not found. Automatic database cleanup will not be set up."
|
||||||
echo "Consider setting up external scheduled tasks to run cleanup scripts."
|
echo "Consider setting up external scheduled tasks to run cleanup scripts."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user