Fix bug involving runcheck
This commit is contained in:
parent
0a7c3aeaab
commit
7973d7c8a6
@ -136,7 +136,7 @@ class API:
|
|||||||
if action == 'hello':
|
if action == 'hello':
|
||||||
resp = Response('Hello, World! ' + request.host)
|
resp = Response('Hello, World! ' + request.host)
|
||||||
elif action == 'shutdown':
|
elif action == 'shutdown':
|
||||||
request.environ.get('werkzeug.server.shutdown')()
|
# request.environ.get('werkzeug.server.shutdown')()
|
||||||
resp = Response('Goodbye')
|
resp = Response('Goodbye')
|
||||||
elif action == 'ping':
|
elif action == 'ping':
|
||||||
resp = Response('pong')
|
resp = Response('pong')
|
||||||
@ -163,7 +163,7 @@ class API:
|
|||||||
time.sleep(self._privateDelayTime - elapsed)
|
time.sleep(self._privateDelayTime - elapsed)
|
||||||
|
|
||||||
return resp
|
return resp
|
||||||
|
|
||||||
@app.route('/')
|
@app.route('/')
|
||||||
def banner():
|
def banner():
|
||||||
self.mimeType = 'text/html'
|
self.mimeType = 'text/html'
|
||||||
|
@ -114,8 +114,9 @@ class OnionrCommunicate:
|
|||||||
elif command[0] == 'runCheck':
|
elif command[0] == 'runCheck':
|
||||||
logger.info('Status check; looks good.')
|
logger.info('Status check; looks good.')
|
||||||
open('data/.runcheck', 'w+').close()
|
open('data/.runcheck', 'w+').close()
|
||||||
break
|
|
||||||
apiRunningCheckCount += 1
|
apiRunningCheckCount += 1
|
||||||
|
|
||||||
# check if local API is up
|
# check if local API is up
|
||||||
if apiRunningCheckCount > apiRunningCheckRate:
|
if apiRunningCheckCount > apiRunningCheckRate:
|
||||||
if self._core._utils.localCommand('ping') != 'pong':
|
if self._core._utils.localCommand('ping') != 'pong':
|
||||||
@ -131,6 +132,7 @@ class OnionrCommunicate:
|
|||||||
apiRunningCheckCount = 0
|
apiRunningCheckCount = 0
|
||||||
|
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|
||||||
self._netController.killTor()
|
self._netController.killTor()
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -400,21 +400,24 @@ class OnionrUtils:
|
|||||||
retData = row[0]
|
retData = row[0]
|
||||||
return retData
|
return retData
|
||||||
|
|
||||||
def isCommunicatorRunning(timeout = 5, interval = 0.1):
|
def isCommunicatorRunning(self, timeout = 5, interval = 0.1):
|
||||||
runcheck_file = 'data/.runcheck'
|
try:
|
||||||
|
runcheck_file = 'data/.runcheck'
|
||||||
|
|
||||||
if os.path.isfile(runcheck_file):
|
|
||||||
os.remove(runcheck_file)
|
|
||||||
logger.debug('%s file appears to have existed before the run check.' % runcheck_file, timestamp = False)
|
|
||||||
|
|
||||||
self._core.daemonQueueAdd('runCheck')
|
|
||||||
starttime = time.time()
|
|
||||||
|
|
||||||
while True:
|
|
||||||
time.sleep(interval)
|
|
||||||
if os.path.isfile(runcheck_file):
|
if os.path.isfile(runcheck_file):
|
||||||
os.remove(runcheck_file)
|
os.remove(runcheck_file)
|
||||||
|
logger.debug('%s file appears to have existed before the run check.' % runcheck_file, timestamp = False)
|
||||||
|
|
||||||
return True
|
self._core.daemonQueueAdd('runCheck')
|
||||||
elif starttime - time.time() >= timeout:
|
starttime = time.time()
|
||||||
return False
|
|
||||||
|
while True:
|
||||||
|
time.sleep(interval)
|
||||||
|
if os.path.isfile(runcheck_file):
|
||||||
|
os.remove(runcheck_file)
|
||||||
|
|
||||||
|
return True
|
||||||
|
elif time.time() - starttime >= timeout:
|
||||||
|
return False
|
||||||
|
except:
|
||||||
|
return False
|
||||||
|
Loading…
Reference in New Issue
Block a user