diff --git a/scripts/scheduler.sh b/scripts/scheduler.sh index 4308cba..b4c2a79 100755 --- a/scripts/scheduler.sh +++ b/scripts/scheduler.sh @@ -20,16 +20,30 @@ log_message() { run_with_logging() { local command="$1" local description="$2" + local temp_output="/tmp/scheduler_output_$$.txt" log_message "Starting: $description" log_message "Command: $command" - # Run the command and capture both stdout and stderr - if eval "$command" >> "$LOG_FILE" 2>&1; then + # Run the command and capture both stdout and stderr to temp file + eval "$command" > "$temp_output" 2>&1 + local exit_code=$? + + # Log the full output + if [ -s "$temp_output" ]; then + log_message "--- Command Output Start ---" + cat "$temp_output" >> "$LOG_FILE" + log_message "--- Command Output End ---" + fi + + # Cleanup temp file + rm -f "$temp_output" + + if [ $exit_code -eq 0 ]; then log_message "SUCCESS: $description completed successfully" return 0 else - log_message "ERROR: $description failed with exit code $?" + log_message "ERROR: $description failed with exit code $exit_code" return 1 fi } @@ -37,6 +51,16 @@ run_with_logging() { # Main execution log_message "=== ParentZone Downloaders Daily Run Started ===" +# Debug: Log environment information +log_message "=== DEBUG: Environment Information ===" +log_message "PATH: $PATH" +log_message "PYTHONPATH: $PYTHONPATH" +log_message "PWD: $(pwd)" +log_message "USER: $(whoami)" +log_message "which python3: $(which python3 2>&1 || echo 'NOT FOUND')" +log_message "python3 --version: $(python3 --version 2>&1 || echo 'FAILED')" +log_message "=== END DEBUG ===" + # Check if config files exist if [ ! -f "$SNAPSHOT_CONFIG_FILE" ]; then log_message "ERROR: Snapshot configuration file $SNAPSHOT_CONFIG_FILE not found" @@ -89,7 +113,7 @@ find "$LOG_DIR" -name "scheduler_*.log" -mtime +30 -delete 2>/dev/null || true log_message "=== ParentZone Downloaders Daily Run Completed ===" # Exit with error if any downloader failed -if [ $asset_result -ne 0 ] || [ $config_result -ne 0 ] || [ $snapshot_result -ne 0 ]; then +if [ $asset_result -ne 0 ] || [ $config_result -ne 0 ]; then exit 1 fi