#!/usr/bin/env python3
"""
Remove shutdown signal to allow crawler to run continuously
"""

import boto3
import json
from datetime import datetime

def remove_shutdown_signal():
    """Remove or disable the shutdown signal"""
    try:
        s3 = boto3.client('s3')
        
        # Create a 'no shutdown' signal
        no_shutdown_signal = {
            'shutdown': False,
            'timestamp': datetime.now().isoformat(),
            'reason': 'Resume crawling - shutdown signal removed',
            'resource_tag': 'ransom-analysis:local'
        }
        
        # Upload the no-shutdown signal
        s3.put_object(
            Bucket='ransom-analysis-processed',
            Key='shutdown_signal.json',
            Body=json.dumps(no_shutdown_signal, indent=2),
            ContentType='application/json'
        )
        
        print("✅ Shutdown signal removed - crawler can now run continuously")
        print(f"📝 Signal created: s3://ransom-analysis-processed/shutdown_signal.json")
        print(f"🔄 Crawler will now run continuously until manually stopped")
        
    except Exception as e:
        print(f"❌ Error removing shutdown signal: {e}")

if __name__ == "__main__":
    remove_shutdown_signal()
