Auto-update: Mon Sep 23 13:17:52 PDT 2024
This commit is contained in:
parent
7abaa9d75c
commit
7799f0af94
1 changed files with 100 additions and 99 deletions
|
@ -6,20 +6,21 @@ import subprocess
|
|||
import time
|
||||
from tqdm import tqdm
|
||||
|
||||
# Configuration variables
|
||||
CONFIG_FILE = 'sys.yaml'
|
||||
POOL_KEY = 'POOL'
|
||||
TABLES_KEY = 'TABLES'
|
||||
SOURCE_INDEX = 0
|
||||
|
||||
def load_config():
|
||||
script_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
project_root = os.path.abspath(os.path.join(script_dir, '..', '..'))
|
||||
sys_config_path = os.path.join(project_root, 'config', 'sys.yaml')
|
||||
gis_config_path = os.path.join(project_root, 'config', 'gis.yaml')
|
||||
config_path = os.path.join(project_root, 'config', CONFIG_FILE)
|
||||
|
||||
with open(sys_config_path, 'r') as f:
|
||||
sys_config = yaml.safe_load(f)
|
||||
|
||||
with open(gis_config_path, 'r') as f:
|
||||
gis_config = yaml.safe_load(f)
|
||||
|
||||
return sys_config, gis_config
|
||||
with open(config_path, 'r') as f:
|
||||
config = yaml.safe_load(f)
|
||||
|
||||
return config
|
||||
|
||||
def get_table_size(server, table_name):
|
||||
env = os.environ.copy()
|
||||
|
@ -118,12 +119,12 @@ def replicate_table(source, targets, table_name):
|
|||
print(f"Replication of {table_name} completed")
|
||||
|
||||
def main():
|
||||
sys_config, gis_config = load_config()
|
||||
config = load_config()
|
||||
|
||||
source_server = sys_config['POOL'][0]
|
||||
target_servers = sys_config['POOL'][1:]
|
||||
source_server = config[POOL_KEY][SOURCE_INDEX]
|
||||
target_servers = config[POOL_KEY][SOURCE_INDEX + 1:]
|
||||
|
||||
tables = [layer['table_name'] for layer in gis_config['layers']]
|
||||
tables = list(config[TABLES_KEY].keys())
|
||||
|
||||
for table in tables:
|
||||
replicate_table(source_server, target_servers, table)
|
||||
|
|
Loading…
Reference in a new issue