Skip to content

Commit

Permalink
Fixed some bugs. Replay now properly causes resync if failed 3 times.…
Browse files Browse the repository at this point in the history
… Feed script launching is functional. although line 176 is currently commented out
  • Loading branch information
gileadmcgee committed Oct 19, 2015
1 parent 54ea2fc commit 21b9d00
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 20 deletions.
2 changes: 1 addition & 1 deletion scripts/switch-keys/config-example.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@
path_to_wallet_json = "/home/user/src/bitshares-2/programs/cli_wallet/wallet.json"


path_to_price_feed_script = "/home/user/src/python-graphenelib/scripts/pricefeeds/pricefeeds.py"
path_to_feed_script = "/home/user/src/python-graphenelib/scripts/pricefeeds/pricefeeds.py"

feed_script_time = 42
48 changes: 29 additions & 19 deletions scripts/switch-keys/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,14 @@

def closeScreens():
print("closing wallet")
time.sleep(15) #adding this to give some time to ctrl-c before --resync if desired
subprocess.call(["screen","-S","wallet","-p","0","-X","quit"])
time.sleep(2)
print("closing witness")
subprocess.call(["screen","-S","witness","-p","0","-X","quit"])
time.sleep(2)
subprocess.call(["pkill","witness_node"])
time.sleep(2)

def openScreens():
print("opening witness")
Expand Down Expand Up @@ -58,25 +62,27 @@ def waitAndNotify():
participation = info["participation"]
print(str(block) + " " + str(age) + " " + str(participation) + " replay = " + str(replay) + " crash = " + str(crash))

def watch(num):
def watch(tries):
if float(info()) < 50:
if num > 2:
if tries > 2:
closeScreens()
resysnc()
resync()
print("unlocking wallet")
rpc.unlock(config.wallet_password)
print("wallet unlocked")
time.sleep(30)
return 0
tries = 0
return tries

else:
closeScreens()
openScreens()
print("unlocking wallet")
rpc.unlock(config.wallet_password)
print("wallet unlocked")
time.sleep(30)
num += 1
return num
tries += 1
return tries
else:
return 0

Expand All @@ -92,20 +98,21 @@ def resync():
time.sleep(10)

### testing running feed schedule through script
#def checkTime():
# hour = strftime("%H", gmtime())
# minute = strftime("%M", gmtime())
# hour = int(hour)
# minute = int(minute)
# if minute % 60 == config.price_feed_time:
# subprocess.call(["screen","-S","feed","-p","0","-X","quit"])
# subprocess.call(["screen","-dmS","feed","python3",config.path_to_feed_script])
# time.sleep(60)
def checkTime():
minute = strftime("%M", gmtime())
minute = int(minute)
if minute % 60 == config.feed_script_time:
subprocess.call(["screen","-S","feed","-p","0","-X","quit"])
subprocess.call(["screen","-dmS","feed","python3",config.path_to_feed$
time.sleep(60)



recentmissed = 0
emergency = False
replay = 0
replay = 3
crash = 0
lastHour = 0
closeScreens()
openScreens()
print("unlocking wallet")
Expand Down Expand Up @@ -166,10 +173,11 @@ def resync():
print(config.witnessname + " missed a block. total missed = " + str(missed) + " recent missed = " + str(recentmissed))
lastblock = witness["last_confirmed_block_num"]
else:
# checkTime()
# lastHour = checkTime(lastHour)
waitAndNotify()
replay = watch(replay)
### if you are having issue try commenting out the try line and everything below the except line to prevent auto restart
tries = replay
replay = watch(tries)
### if you are having issue try commenting out the try line (126) and everything below the except line to prevent auto restart
except:
try:
if crash > 2:
Expand Down Expand Up @@ -225,3 +233,5 @@ def resync():
rpc.unlock(config.wallet_password)




0 comments on commit 21b9d00

Please sign in to comment.