X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/6ddb39fda342618cf0929a5b85973dfa8aa2c17c..6a748204fffd43722788aacdd341ba8961a5a4fb:/nominatim/clicmd/replication.py?ds=sidebyside diff --git a/nominatim/clicmd/replication.py b/nominatim/clicmd/replication.py index ad201663..192a9314 100644 --- a/nominatim/clicmd/replication.py +++ b/nominatim/clicmd/replication.py @@ -142,15 +142,18 @@ class UpdateReplication: if not args.do_index: LOG.fatal("Indexing cannot be disabled when running updates continuously.") raise UsageError("Bad argument '--no-index'.") - recheck_interval = args.config.get_int('REPLICATION_RECHECK_INTERVAL') + recheck_interval = args.config.get_int('REPLICATION_RECHECK_INTERVAL') tokenizer = tokenizer_factory.get_tokenizer_for_db(args.config) indexer = Indexer(args.config.get_libpq_dsn(), tokenizer, args.threads or 1) + dsn = args.config.get_libpq_dsn() + while True: - with connect(args.config.get_libpq_dsn()) as conn: - start = dt.datetime.now(dt.timezone.utc) - state = replication.update(conn, params, socket_timeout=args.socket_timeout) + start = dt.datetime.now(dt.timezone.utc) + state = replication.update(dsn, params, socket_timeout=args.socket_timeout) + + with connect(dsn) as conn: if state is not replication.UpdateState.NO_CHANGES: status.log_status(conn, start, 'import') batchdate, _, _ = status.get_status(conn) @@ -160,7 +163,7 @@ class UpdateReplication: index_start = dt.datetime.now(dt.timezone.utc) indexer.index_full(analyse=False) - with connect(args.config.get_libpq_dsn()) as conn: + with connect(dsn) as conn: status.set_indexed(conn, True) status.log_status(conn, index_start, 'index') conn.commit()