fix daemon shutdown

This commit is contained in:
Alex Grintsvayg 2017-08-02 17:21:24 -04:00
parent ddcf3a47f8
commit ea9d368d09
3 changed files with 9 additions and 18 deletions

View file

@ -20,6 +20,9 @@ at anytime.
### Fixed ### Fixed
* *
* *
* Fixed incorrect formatting of "amount" fields
* Fixed handling of SIGINT, SIGTERM.
* Fixed shutdown sequence
### Deprecated ### Deprecated
* The API will no longer be served at the /lbryapi path. It will now be at the root. * The API will no longer be served at the /lbryapi path. It will now be at the root.

View file

@ -18,18 +18,8 @@ def test_internet_connection():
return utils.check_connection() return utils.check_connection()
def stop():
conf.initialize_settings()
log_support.configure_console()
try:
LBRYAPIClient.get_client().call('stop')
except Exception:
log.exception('Failed to stop deamon')
else:
log.info("Shutting down lbrynet-daemon from command line")
def start(): def start():
"""The primary entry point for launching the daemon."""
conf.initialize_settings() conf.initialize_settings()
parser = argparse.ArgumentParser(description="Launch lbrynet-daemon") parser = argparse.ArgumentParser(description="Launch lbrynet-daemon")
@ -107,10 +97,9 @@ def start_server_and_listen(use_auth, analytics_manager):
yield daemon_server.start(use_auth) yield daemon_server.start(use_auth)
analytics_manager.send_server_startup_success() analytics_manager.send_server_startup_success()
except Exception as e: except Exception as e:
log.exception('Failed to startup') log.exception('Failed to start')
yield daemon_server.stop()
analytics_manager.send_server_startup_error(str(e)) analytics_manager.send_server_startup_error(str(e))
reactor.fireSystemEvent("shutdown") daemon_server.stop()
if __name__ == "__main__": if __name__ == "__main__":

View file

@ -54,10 +54,9 @@ class DaemonServer(object):
@defer.inlineCallbacks @defer.inlineCallbacks
def stop(self): def stop(self):
if self._api is not None: if reactor.running:
yield self._api._shutdown() log.info("Stopping the reactor")
if self.server_port is not None: reactor.fireSystemEvent("shutdown")
yield self.server_port.stopListening()
def get_site_base(use_auth, root): def get_site_base(use_auth, root):