def sync_cli(argv=sys.argv): parser = argparse.ArgumentParser(description="""Start synchronization daemon This daemon connects to zookeeper an watches for changes to the database config. It then notifies it's plugins when the state changes. A built-in plugin is zgres-apply which writes the config out to /var/lib/zgres/databases.json whenever there is a change and calls zgres-apply to run arbitrary executables dropped into /var/lib/zgres/hooks. This daemon gets run on all machines which need to know the database connection info, that means appservers and probably database nodes if you use streaming replication. """) config = zgres.config.parse_args(parser, argv, config_file='sync.ini') # Keep a reference to the App to prevent garbage collection app = SyncApp(config) utils.run_asyncio() sys.exit(0)
def sync_cli(argv=sys.argv): parser = argparse.ArgumentParser(description="""Start synchronization daemon This daemon connects to zookeeper an watches for changes to the database config. It then notifies it's plugins when the state changes. A built-in plugin is zgres-apply which writes the config out to /var/lib/zgres/databases.json whenever there is a change and calls zgres-apply to run arbitrary executables dropped into /var/lib/zgres/hooks. This daemon gets run on all machines which need to know the database connection info, that means appservers and probably database nodes if you use streaming replication. """) config = zgres.config.parse_args(parser, argv) # Keep a reference to the App to prevent garbage collection app = App(config) utils.run_asyncio() sys.exit(0)
def deadman_cli(argv=sys.argv): parser = argparse.ArgumentParser(description="""Monitors/controls the local postgresql installation. This daemon will do these things: - Register the local postgresql instance with Zookeeper by creating a file named the IP address to connect on. - Try to become master by creating the file: master-{cluster_name} in zookeeper. If we suceed we create the file /tmp/zgres_become_master. - Shutdown postgres temporarily if we are master and the zookeeper connection is lost. - Shutdown postgres permanently if master-{cluster_name} already exists and we didn't create it (split-brain avoidance) - Monitor the local postgresql installation, if it becomes unavailable, withdraw our zookeeper registrations. It does not: - maintain streaming replication (use zgres-apply hooks for that) - do remastering (assumed to have happened before we start) """) config = zgres.config.parse_args(parser, argv, config_file='deadman.ini') result = utils.run_asyncio(App.run, config) sys.exit(result)