mirror of
https://github.com/anyproto/any-sync-dockercompose.git
synced 2025-06-08 05:47:03 +09:00
generate nodes.yml file for netcheck tool
This commit is contained in:
parent
ef3158740b
commit
885a84bfb9
2 changed files with 18 additions and 3 deletions
|
@ -221,11 +221,11 @@ services:
|
|||
- any-sync-node-2
|
||||
- any-sync-node-3
|
||||
volumes:
|
||||
- ./etc/client.yml:/client.yml:Z
|
||||
- ./etc/nodes.yml:/nodes.yml:Z
|
||||
command: ["tail", "-f", "/dev/null"]
|
||||
stop_signal: SIGKILL
|
||||
tty: true
|
||||
healthcheck:
|
||||
test: any-sync-netcheck -c /client.yml 2>&1| grep -E 'netcheck\s+success'
|
||||
test: any-sync-netcheck -c /nodes.yml 2>&1| grep -E 'netcheck\s+success'
|
||||
interval: 10s
|
||||
start_period: 5s
|
|
@ -104,6 +104,18 @@ def write_config():
|
|||
if file in ('config.yml', 'network.yml', 'client.yml'):
|
||||
update_config_file(os.path.join(root, file), ids_data, network_info)
|
||||
|
||||
# retrieve node internal addresses from client.yml to send to netcheck tool
|
||||
def prepare_netcheck_config(input_path: str, output_path: str):
|
||||
with open(input_path, "r") as file:
|
||||
data = yaml.safe_load(file)
|
||||
|
||||
for node in data.get("nodes", []):
|
||||
if "addresses" in node:
|
||||
node["addresses"] = node["addresses"][:2]
|
||||
|
||||
with open(output_path, "w") as file:
|
||||
yaml.dump(data, file, default_flow_style=False)
|
||||
|
||||
if __name__ == "__main__":
|
||||
# Check if ids.yml exists and decide whether to read or write configurations
|
||||
if os.path.exists(IDS_FILE):
|
||||
|
@ -111,4 +123,7 @@ if __name__ == "__main__":
|
|||
write_config()
|
||||
else:
|
||||
logging.info(f'{IDS_FILE} not found! Reading current accounts and network identifiers...')
|
||||
read_config()
|
||||
read_config()
|
||||
|
||||
logging.info(f'Generate nodes.yml config for netcheck tool...')
|
||||
prepare_netcheck_config("etc/client.yml", "etc/nodes.yml")
|
Loading…
Add table
Add a link
Reference in a new issue