mirror of
https://github.com/mynodebtc/mynode.git
synced 2024-11-12 08:29:16 +00:00
Improve check in success
This commit is contained in:
parent
99bda4e0e3
commit
efd14c76d3
|
@ -16,6 +16,7 @@ Nice=-15
|
||||||
IOAccounting=true
|
IOAccounting=true
|
||||||
IOWeight=2000
|
IOWeight=2000
|
||||||
ExecStart=/usr/bin/python /var/www/mynode/mynode.py
|
ExecStart=/usr/bin/python /var/www/mynode/mynode.py
|
||||||
|
ExecStartPost=/usr/bin/mynode_post_www.sh
|
||||||
User=root
|
User=root
|
||||||
Group=root
|
Group=root
|
||||||
StandardOutput=syslog
|
StandardOutput=syslog
|
||||||
|
|
10
rootfs/standard/usr/bin/mynode_post_www.sh
Executable file
10
rootfs/standard/usr/bin/mynode_post_www.sh
Executable file
|
@ -0,0 +1,10 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
source /usr/share/mynode/mynode_config.sh
|
||||||
|
|
||||||
|
set -x
|
||||||
|
|
||||||
|
sleep 10s
|
||||||
|
|
||||||
|
# Load webpage once to trigger initial load
|
||||||
|
curl http://localhost/
|
|
@ -175,10 +175,17 @@ def check_in():
|
||||||
session.proxies['https'] = 'socks5h://localhost:9050'
|
session.proxies['https'] = 'socks5h://localhost:9050'
|
||||||
|
|
||||||
# Check In
|
# Check In
|
||||||
|
fail_count = 0
|
||||||
check_in_success = False
|
check_in_success = False
|
||||||
while not check_in_success:
|
while not check_in_success:
|
||||||
try:
|
try:
|
||||||
r = session.post(CHECKIN_URL, data=data, timeout=10)
|
# Use tor for check in unless there have been tor 10 failures in a row
|
||||||
|
r = None
|
||||||
|
if (fail_count+1) % 10 == 0:
|
||||||
|
r = requests.post(CHECKIN_URL, data=data, timeout=15)
|
||||||
|
else:
|
||||||
|
r = session.post(CHECKIN_URL, data=data, timeout=15)
|
||||||
|
|
||||||
if r.status_code == 200:
|
if r.status_code == 200:
|
||||||
if r.text == "OK":
|
if r.text == "OK":
|
||||||
os.system("printf \"%s | Check In Success: {} \\n\" \"$(date)\" >> /tmp/check_in_status".format(r.text))
|
os.system("printf \"%s | Check In Success: {} \\n\" \"$(date)\" >> /tmp/check_in_status".format(r.text))
|
||||||
|
@ -198,8 +205,9 @@ def check_in():
|
||||||
os.system("printf \"%s | Check In Failed. Retrying... Exception {} \\n\" \"$(date)\" >> /tmp/check_in_status".format(e))
|
os.system("printf \"%s | Check In Failed. Retrying... Exception {} \\n\" \"$(date)\" >> /tmp/check_in_status".format(e))
|
||||||
|
|
||||||
if not check_in_success:
|
if not check_in_success:
|
||||||
# Check in failed, try again in 2 minutes
|
# Check in failed, try again in 3 minutes
|
||||||
os.system("touch /tmp/check_in_error")
|
os.system("touch /tmp/check_in_error")
|
||||||
time.sleep(120)
|
time.sleep(180)
|
||||||
|
fail_count = fail_count + 1
|
||||||
|
|
||||||
return True
|
return True
|
Loading…
Reference in New Issue
Block a user