Skip to content

Commit

Permalink
Move this idea of reboots (which now work) into prod
Browse files Browse the repository at this point in the history
  • Loading branch information
Jbithell committed Aug 19, 2017
1 parent 15e9f90 commit 749e485
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import sys #To kill app
import serial
import time #For time.sleep
import struct #To merge two bytes in an integer
Expand All @@ -24,13 +25,10 @@ def reboot():
log("Rebooting")
rebooturl = str(os.environ.get('RESIN_SUPERVISOR_ADDRESS')) + '/v1/reboot?apikey=' + str(os.environ.get('RESIN_SUPERVISOR_API_KEY'))
os.system('curl -X POST --header "Content-Type:application/json" "$RESIN_SUPERVISOR_ADDRESS/v1/reboot?apikey=$RESIN_SUPERVISOR_API_KEY"')
'''
requestResponse = urllib.request.urlopen(rebooturl)
requestParsedResponse = json.loads(requestResponse.read().decode('utf-8'))
if requestParsedResponse["Data"] != "OK":
print(requestParsedResponse["Error"])
'''
reboot()
time.sleep(60) #Just in case that api call fails as it sometimes does
os.system('curl -X POST --header "Content-Type:application/json" "$RESIN_SUPERVISOR_ADDRESS/v1/reboot?apikey=$RESIN_SUPERVISOR_API_KEY"')
time.sleep(60) # Just in case that api call fails AGAIN as it sometimes does
sys.exit() #This forces a container restart anyway

sqliteconn = sqlite3.connect("/data/weatherdatabase.sqlite3")

Expand Down

0 comments on commit 749e485

Please sign in to comment.