This repository has been archived by the owner on Oct 17, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ff55579
commit 4df7305
Showing
6 changed files
with
96 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#!/usr/bin/env python3 | ||
"""Generate a workers.json file | ||
""" | ||
|
||
import sys | ||
import argparse | ||
import json | ||
|
||
|
||
def main(): | ||
"mainly main." | ||
parser = argparse.ArgumentParser( | ||
description="workers file generator") | ||
|
||
parser.add_argument("-np", default=4, type=int, | ||
help="number of primary instances") | ||
parser.add_argument("-nw", default=1, type=int, | ||
help="number of worker instances per primary") | ||
parser.add_argument("-f", default="workers.json", | ||
help="workers.json file name") | ||
parser.add_argument("-d", default=None, help="target directory") | ||
args = parser.parse_args() | ||
|
||
# load keys | ||
keys = [] | ||
for i in range(args.np): | ||
k = open("{}/validator-{:02d}/key.json".format(args.d, i)).read() | ||
keys.append(json.loads(k)) | ||
|
||
temp = {} | ||
starting_port = 4000 | ||
for i, k in enumerate(keys): | ||
workers = {} | ||
port = starting_port | ||
for i in range(args.nw): | ||
workers[i] = { | ||
"primary_to_worker": "/dns/worker_{:02d}/tcp/{}/http".format(i, port), | ||
"transactions": "/dns/worker_{:02d}/tcp/{}/http".format(i, port+1), | ||
"worker_to_worker": "/dns/worker_{:02d}/tcp/{}/http".format(i, port+2) | ||
} | ||
port += 3 | ||
temp[k['name']] = workers | ||
out = {"workers": temp, "epoch": 0} | ||
print(json.dumps(out, indent=4)) | ||
|
||
|
||
if __name__ == '__main__': | ||
sys.exit(main()) |