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
|
import time
|
||||||
from tqdm import tqdm
|
from tqdm import tqdm
|
||||||
|
|
||||||
|
# Configuration variables
|
||||||
|
CONFIG_FILE = 'sys.yaml'
|
||||||
|
POOL_KEY = 'POOL'
|
||||||
|
TABLES_KEY = 'TABLES'
|
||||||
|
SOURCE_INDEX = 0
|
||||||
|
|
||||||
def load_config():
|
def load_config():
|
||||||
script_dir = os.path.dirname(os.path.abspath(__file__))
|
script_dir = os.path.dirname(os.path.abspath(__file__))
|
||||||
project_root = os.path.abspath(os.path.join(script_dir, '..', '..'))
|
project_root = os.path.abspath(os.path.join(script_dir, '..', '..'))
|
||||||
sys_config_path = os.path.join(project_root, 'config', 'sys.yaml')
|
config_path = os.path.join(project_root, 'config', CONFIG_FILE)
|
||||||
gis_config_path = os.path.join(project_root, 'config', 'gis.yaml')
|
|
||||||
|
|
||||||
with open(sys_config_path, 'r') as f:
|
with open(config_path, 'r') as f:
|
||||||
sys_config = yaml.safe_load(f)
|
config = yaml.safe_load(f)
|
||||||
|
|
||||||
with open(gis_config_path, 'r') as f:
|
|
||||||
gis_config = yaml.safe_load(f)
|
|
||||||
|
|
||||||
return sys_config, gis_config
|
|
||||||
|
|
||||||
|
return config
|
||||||
|
|
||||||
def get_table_size(server, table_name):
|
def get_table_size(server, table_name):
|
||||||
env = os.environ.copy()
|
env = os.environ.copy()
|
||||||
|
@ -118,12 +119,12 @@ def replicate_table(source, targets, table_name):
|
||||||
print(f"Replication of {table_name} completed")
|
print(f"Replication of {table_name} completed")
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
sys_config, gis_config = load_config()
|
config = load_config()
|
||||||
|
|
||||||
source_server = sys_config['POOL'][0]
|
source_server = config[POOL_KEY][SOURCE_INDEX]
|
||||||
target_servers = sys_config['POOL'][1:]
|
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:
|
for table in tables:
|
||||||
replicate_table(source_server, target_servers, table)
|
replicate_table(source_server, target_servers, table)
|
||||||
|
|
Loading…
Reference in a new issue