by NDizzle · 5y ago · 0 comments
It's worked unbelievably well. It's been running for roughly 5 years at this point. I send a command at a random time between 11pm and 4am to wake up an ec2 instance. It checks its tags to see if it should execute the script. If so, it does so. When it's done with its scraping for the day, it turns itself off.
This is a tiny snapshot of why it's been so difficult for me to go from python2 to python3. I'm strongly in the camp of "if it ain't broke, don't fix it".
Any chance you could tell me your setup for this?
* Set an autoscaling group with your instance template, max instances 1, min instances 0, desired instances 0 (nothing is running).
* Set up a Lambda function that sets the autoscaling group desired instances to 1.
* Link that function to an API Gateway call, give it an auth key, etc.
* From any machine you have, set up your cron with a random sleep and a curl call to the API.
And that should do the trick, I think.
You might as well just call the ASG API directly.
My only recent change is that we no longer use Items and ItemLoaders from scrapy - we've replaced it with a custom pipeline of Pydantic schemas and objects