I have a Python script that manages Pushbullet channels for Nexus Android device factory images. It runs on my VPS (cron job that runs every 10 minutes), but my provider has warned that there may be intermittent downtime over the next several days. The VPS is running Ubuntu Server 15.04.
I have a Raspberry Pi that's always on, and I can easily modify the script so that it works independently on both the VPS and the Pi. I would like the primary functionality to exist on the VPS, but I want to fall back to the Pi if the VPS goes down. What would be the best way to facilitate this handoff between the two systems (in both directions)? The Pi is running Raspbian Wheezy.
Additionally, the script uses urlwatch to actually watch the requisite page for updates. It keeps a cache file on the local system for each URL. If the Pi takes over and determines a change is made, it will notify the Pushbullet channel(s) as it should. When the VPS comes back up and takes over, it will have the old cache files and will notify the channel(s) again, which I want to avoid.
So: How can I properly run the script on whichever system happens to be up at the moment (preferring the VPS), and how can I manage the urlwatch caches between the two systems?
Could you shutdown the script on your VPS, copy the cache files over the the Pi and run the script there?  Then do the reverse when you want to move it back to the VPS.
You could possibly run the script on both systems, but then you'd need to synchronize between them which sounds like a lot of unnecessary work.  For instance you could run a third server that you can check with to see if you've sent something yet, but you would need to be able to lock items on there so you don't have a race condition between your two scripts.
Python script fallback to second server