This commit is contained in:
39
scheduler.sh
39
scheduler.sh
@@ -5,7 +5,8 @@
|
|||||||
|
|
||||||
LOG_DIR="/app/logs"
|
LOG_DIR="/app/logs"
|
||||||
LOG_FILE="$LOG_DIR/scheduler_$(date +%Y%m%d).log"
|
LOG_FILE="$LOG_DIR/scheduler_$(date +%Y%m%d).log"
|
||||||
CONFIG_FILE="/app/snapshot_config.json"
|
SNAPSHOT_CONFIG_FILE="/app/snapshot_config.json"
|
||||||
|
ASSET_CONFIG_FILE="/app/parentzone_config.json"
|
||||||
|
|
||||||
# Create log directory if it doesn't exist
|
# Create log directory if it doesn't exist
|
||||||
mkdir -p "$LOG_DIR"
|
mkdir -p "$LOG_DIR"
|
||||||
@@ -36,16 +37,32 @@ run_with_logging() {
|
|||||||
# Main execution
|
# Main execution
|
||||||
log_message "=== ParentZone Downloaders Daily Run Started ==="
|
log_message "=== ParentZone Downloaders Daily Run Started ==="
|
||||||
|
|
||||||
# Check if config file exists
|
# Check if config files exist
|
||||||
if [ ! -f "$CONFIG_FILE" ]; then
|
if [ ! -f "$SNAPSHOT_CONFIG_FILE" ]; then
|
||||||
log_message "ERROR: Configuration file $CONFIG_FILE not found"
|
log_message "ERROR: Snapshot configuration file $SNAPSHOT_CONFIG_FILE not found"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ ! -f "$ASSET_CONFIG_FILE" ]; then
|
||||||
|
log_message "WARNING: Asset configuration file $ASSET_CONFIG_FILE not found, skipping asset downloader"
|
||||||
|
SKIP_ASSET_DOWNLOADER=true
|
||||||
|
else
|
||||||
|
SKIP_ASSET_DOWNLOADER=false
|
||||||
|
fi
|
||||||
|
|
||||||
cd /app
|
cd /app
|
||||||
|
|
||||||
|
# Run config-based asset downloader
|
||||||
|
if [ "$SKIP_ASSET_DOWNLOADER" = false ]; then
|
||||||
|
run_with_logging "python3 config_downloader.py --config $ASSET_CONFIG_FILE" "Config Asset Downloader"
|
||||||
|
asset_result=$?
|
||||||
|
else
|
||||||
|
log_message "SKIPPED: Config Asset Downloader (configuration file not found)"
|
||||||
|
asset_result=0
|
||||||
|
fi
|
||||||
|
|
||||||
# Run config-based snapshot downloader
|
# Run config-based snapshot downloader
|
||||||
run_with_logging "python3 config_snapshot_downloader.py --config $CONFIG_FILE" "Config Snapshot Downloader"
|
run_with_logging "python3 config_snapshot_downloader.py --config $SNAPSHOT_CONFIG_FILE" "Config Snapshot Downloader"
|
||||||
config_result=$?
|
config_result=$?
|
||||||
|
|
||||||
# Run regular snapshot downloader with environment variables
|
# Run regular snapshot downloader with environment variables
|
||||||
@@ -62,6 +79,16 @@ fi
|
|||||||
|
|
||||||
# Summary
|
# Summary
|
||||||
log_message "=== Daily Run Summary ==="
|
log_message "=== Daily Run Summary ==="
|
||||||
|
if [ "$SKIP_ASSET_DOWNLOADER" = false ]; then
|
||||||
|
if [ $asset_result -eq 0 ]; then
|
||||||
|
log_message "✓ Config Asset Downloader: SUCCESS"
|
||||||
|
else
|
||||||
|
log_message "✗ Config Asset Downloader: FAILED"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
log_message "- Config Asset Downloader: SKIPPED"
|
||||||
|
fi
|
||||||
|
|
||||||
if [ $config_result -eq 0 ]; then
|
if [ $config_result -eq 0 ]; then
|
||||||
log_message "✓ Config Snapshot Downloader: SUCCESS"
|
log_message "✓ Config Snapshot Downloader: SUCCESS"
|
||||||
else
|
else
|
||||||
@@ -80,7 +107,7 @@ find "$LOG_DIR" -name "scheduler_*.log" -mtime +30 -delete 2>/dev/null || true
|
|||||||
log_message "=== ParentZone Downloaders Daily Run Completed ==="
|
log_message "=== ParentZone Downloaders Daily Run Completed ==="
|
||||||
|
|
||||||
# Exit with error if any downloader failed
|
# Exit with error if any downloader failed
|
||||||
if [ $config_result -ne 0 ] || [ $snapshot_result -ne 0 ]; then
|
if [ $asset_result -ne 0 ] || [ $config_result -ne 0 ] || [ $snapshot_result -ne 0 ]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user