fix bug where onionr would complain while restarting about not being able to start

This commit is contained in:
Kevin 2020-06-27 18:03:20 -05:00
parent c5fd39c762
commit b878faeb4c
3 changed files with 11 additions and 1 deletions

View File

@ -36,3 +36,5 @@ onboarding_mark_file = home + 'onboarding-completed'
log_file = home + 'onionr.log'
ephemeral_services_file = home + 'ephemeral-services.list'
restarting_indicator = home + "is-restarting"

View File

@ -214,6 +214,13 @@ def start(override: bool = False):
Error exit if there is and its not overridden
"""
if os.path.exists(filepaths.lock_file) and not override:
if os.path.exists(filepaths.restarting_indicator):
try:
os.remove(filepaths.restarting_indicator)
except FileNotFoundError:
pass
else:
return
logger.fatal('Cannot start. Daemon is already running,'
+ ' or it did not exit cleanly.\n'
+ ' (if you are sure that there is not a daemon running,'

View File

@ -49,7 +49,8 @@ def restart():
return
except (AttributeError, OSError):
logger.warn('Could not fork on restart')
with open(filepaths.restarting_indicator, 'w') as f:
f.write('t')
daemonlaunch.kill_daemon()
while localcommand.local_command('ping', maxWait=8) == 'pong!':
time.sleep(0.3)