Stop the daemon on calling lbrynet stop

This commit is contained in:
hackrush 2019-02-14 00:32:55 +05:30 committed by Lex Berezhny
parent 119d498bce
commit 21ca4f60f7
2 changed files with 3 additions and 1 deletions

View file

@ -274,7 +274,7 @@ def main(argv=None):
daemon = Daemon(conf)
try:
loop.run_until_complete(daemon.start())
loop.run_forever()
loop.run_until_complete(daemon.stop_event.wait())
except (GracefulExit, KeyboardInterrupt):
pass
finally:

View file

@ -257,6 +257,7 @@ class Daemon(metaclass=JSONRPCServerType):
)
self.component_startup_task = None
self._connection_status: typing.Tuple[float, bool] = [self.component_manager.loop.time(), False]
self.stop_event = asyncio.Event()
logging.getLogger('aiohttp.access').setLevel(logging.WARN)
app = web.Application()
@ -604,6 +605,7 @@ class Daemon(metaclass=JSONRPCServerType):
(string) Shutdown message
"""
log.info("Shutting down lbrynet daemon")
self.stop_event.set()
return "Shutting down"
async def jsonrpc_status(self):