Stop the daemon on calling lbrynet stop
This commit is contained in:
parent
119d498bce
commit
21ca4f60f7
2 changed files with 3 additions and 1 deletions
|
@ -274,7 +274,7 @@ def main(argv=None):
|
||||||
daemon = Daemon(conf)
|
daemon = Daemon(conf)
|
||||||
try:
|
try:
|
||||||
loop.run_until_complete(daemon.start())
|
loop.run_until_complete(daemon.start())
|
||||||
loop.run_forever()
|
loop.run_until_complete(daemon.stop_event.wait())
|
||||||
except (GracefulExit, KeyboardInterrupt):
|
except (GracefulExit, KeyboardInterrupt):
|
||||||
pass
|
pass
|
||||||
finally:
|
finally:
|
||||||
|
|
|
@ -257,6 +257,7 @@ class Daemon(metaclass=JSONRPCServerType):
|
||||||
)
|
)
|
||||||
self.component_startup_task = None
|
self.component_startup_task = None
|
||||||
self._connection_status: typing.Tuple[float, bool] = [self.component_manager.loop.time(), False]
|
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)
|
logging.getLogger('aiohttp.access').setLevel(logging.WARN)
|
||||||
app = web.Application()
|
app = web.Application()
|
||||||
|
@ -604,6 +605,7 @@ class Daemon(metaclass=JSONRPCServerType):
|
||||||
(string) Shutdown message
|
(string) Shutdown message
|
||||||
"""
|
"""
|
||||||
log.info("Shutting down lbrynet daemon")
|
log.info("Shutting down lbrynet daemon")
|
||||||
|
self.stop_event.set()
|
||||||
return "Shutting down"
|
return "Shutting down"
|
||||||
|
|
||||||
async def jsonrpc_status(self):
|
async def jsonrpc_status(self):
|
||||||
|
|
Loading…
Reference in a new issue