mirror of
https://github.com/stronk-dev/RewardCaller.git
synced 2025-07-07 06:45:09 +02:00
cleanup & readme update
This commit is contained in:
parent
aa1905a315
commit
2dca6b4bc6
32
README.md
32
README.md
@ -1,2 +1,34 @@
|
|||||||
# better-call-reward
|
# better-call-reward
|
||||||
Script calling 'reward' for Livepeer orchestrator
|
Script calling 'reward' for Livepeer orchestrator
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
usage: better-call-reward.py [-h] [-url [URL]] [-delay [DELAY]]
|
||||||
|
|
||||||
|
Optional app description
|
||||||
|
|
||||||
|
optional arguments:
|
||||||
|
-h, --help show this help message and exit
|
||||||
|
-url [URL] URL for your Orchestrator
|
||||||
|
-delay [DELAY] delay between next try of call "reward"
|
||||||
|
|
||||||
|
example usage:
|
||||||
|
./better-call-reward.py -url http://localhost:7935
|
||||||
|
or use
|
||||||
|
|
||||||
|
some error:
|
||||||
|
Orchestrator URL: http://192.168.137.103:7935
|
||||||
|
Connection success
|
||||||
|
---Info---
|
||||||
|
Orchestrator Version: 0.5.31-ec920c67
|
||||||
|
GolangRuntimeVersion: go1.18.1
|
||||||
|
|
||||||
|
Transcoders:
|
||||||
|
[1] Address: 127.0.0.1:54396 Capacity:14
|
||||||
|
|
||||||
|
[ 2022-06-02 10:33:26.291112 ] Orchestrator status: online
|
||||||
|
[ 2022-06-02 10:33:26.291156 ] Last reward round: 2584
|
||||||
|
[ 2022-06-02 10:33:26.291175 ] Current round: 2585
|
||||||
|
[ 2022-06-02 10:33:26.291189 ] Call reward!
|
||||||
|
[ 2022-06-02 10:33:26.292445 ] <Response [404]>
|
||||||
|
[ 2022-06-02 10:33:26.292469 ] Call reward fail. Error: <Response [404]>
|
@ -2,34 +2,27 @@
|
|||||||
from asyncio import constants
|
from asyncio import constants
|
||||||
from pyclbr import Function
|
from pyclbr import Function
|
||||||
import requests
|
import requests
|
||||||
import json
|
|
||||||
import time
|
import time
|
||||||
import sys
|
import sys
|
||||||
import argparse
|
import argparse
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
import logging
|
|
||||||
|
|
||||||
# set your Orchestrator url
|
# set your Orchestrator url
|
||||||
# orchUrl = 'http://192.168.137.103:7935'
|
|
||||||
URL_DEFAULT = 'http://localhost:7935' # default
|
URL_DEFAULT = 'http://localhost:7935' # default
|
||||||
waitTime = 60 * 60 # check reward every 1 hour (value in second)
|
|
||||||
waitTime = 15
|
|
||||||
|
|
||||||
retryTimeOffline = 60 # delay when O is offline in second
|
retryTimeOffline = 60 # delay when O is offline, in seconds
|
||||||
retryTimeReward = 60 * 60 # time for check and call reward in second
|
retryTimeReward = 60 * 60 # time retry call "reward ", in seconds
|
||||||
|
|
||||||
|
|
||||||
def my_function():
|
|
||||||
print("Hello from a function")
|
|
||||||
|
|
||||||
|
|
||||||
def parseArgs():
|
def parseArgs():
|
||||||
# Instantiate the parser
|
# Instantiate the parser
|
||||||
parser = argparse.ArgumentParser(description='Optional app description')
|
parser = argparse.ArgumentParser(
|
||||||
|
description='Script to resolve problem with livepeer "reward" call. ')
|
||||||
parser.add_argument('-url', type=str, nargs='?',
|
parser.add_argument('-url', type=str, nargs='?',
|
||||||
help='URL for your Orchestrator')
|
help='URL for your Orchestrator')
|
||||||
parser.add_argument('-delay', type=int, nargs='?',
|
# todo: ? add delay params
|
||||||
help='delay between next try of call "reward"')
|
# parser.add_argument('-delay', type=int, nargs='?',
|
||||||
|
# help='delay between next try of call "reward"')
|
||||||
# Parse the argument
|
# Parse the argument
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
if args.url is None:
|
if args.url is None:
|
||||||
@ -40,10 +33,8 @@ def parseArgs():
|
|||||||
return url
|
return url
|
||||||
# end parseArgs()
|
# end parseArgs()
|
||||||
|
|
||||||
# check O status and get some info
|
|
||||||
|
|
||||||
|
def statusOrch(url): # /status , check O status and get some info
|
||||||
def statusOrch(url): # /status
|
|
||||||
try:
|
try:
|
||||||
r = requests.get(url + '/status')
|
r = requests.get(url + '/status')
|
||||||
responseStatus = r.status_code
|
responseStatus = r.status_code
|
||||||
@ -53,7 +44,7 @@ def statusOrch(url): # /status
|
|||||||
exit(0)
|
exit(0)
|
||||||
print("Connection success")
|
print("Connection success")
|
||||||
print("---Info---")
|
print("---Info---")
|
||||||
print("Version: " + r.json()['Version'])
|
print("Orchestrator Version: " + r.json()['Version'])
|
||||||
print("GolangRuntimeVersion: " + r.json()['GolangRuntimeVersion'])
|
print("GolangRuntimeVersion: " + r.json()['GolangRuntimeVersion'])
|
||||||
print("")
|
print("")
|
||||||
|
|
||||||
@ -131,12 +122,12 @@ while True:
|
|||||||
|
|
||||||
if currentRound != lastRewardRound:
|
if currentRound != lastRewardRound:
|
||||||
log('Call reward!')
|
log('Call reward!')
|
||||||
r = requests.get(url + '/rewardss') # call reward
|
r = requests.get(url + '/reward') # call reward
|
||||||
log(r)
|
log(r)
|
||||||
if r.status_code == 200:
|
if r.status_code == 200:
|
||||||
log('Call reward success.')
|
log('Call to reward success.')
|
||||||
else:
|
else:
|
||||||
log('Call reward fail. Error: ' + str(r))
|
log('Call to reward fail. Error: ' + str(r))
|
||||||
|
|
||||||
else:
|
else:
|
||||||
log('Do not call reward. ' + 'Reward for current round ' +
|
log('Do not call reward. ' + 'Reward for current round ' +
|
||||||
|
Loading…
x
Reference in New Issue
Block a user