Bunch of fixes

Signed-off-by: fly <merspieler@airmail.cc>
This commit is contained in:
fly 2020-01-15 11:33:31 +00:00
parent 7116fc64f9
commit e08fbea737
2 changed files with 79 additions and 64 deletions

View file

@ -41,9 +41,8 @@ while i < argc:
i += 1
sfile = sys.argv[i]
elif sys.argv[i] == "-h" or sys.argv[i] == "--help":
print("usage: wb-progress-logger.py [OPTIONS]")
print("Logs progress of the worldbuild when run")
print("with database strategies 'chunk' and 'mono'")
print("usage: worldbuild-manager.py [OPTIONS]")
print("Handles job asignments and keeps track of the status")
print("")
print("OPTIONS")
print(" -f, --file Status file to use")
@ -51,6 +50,7 @@ while i < argc:
print(" , --host hostname or interface to bind to")
print(" , --port Port to bind to")
print(" -h, --help Shows this help and exit")
sys.exit(0)
else:
print("Unknown option " + sys.argv[i])
sys.exit(1)
@ -62,7 +62,7 @@ def norm(num, length):
num = "0" + num
return num
def save_state(state)
def save_state(state):
try:
with open(sfile, 'w') as f:
json.dump(state, f, indent=4)
@ -165,9 +165,9 @@ try:
elif action == "get":
tile = ""
# Build poles first
if not "n-pole" in status or ("n-pole" in status and status["n-pole"]["status"] == get):
if not "n-pole" in state or ("n-pole" in state and state["n-pole"]["status"] == get):
tile = "n-pole"
elif not "s-pole" in status or ("s-pole" in status and status["s-pole"]["status"] == get):
elif not "s-pole" in state or ("s-pole" in state and state["s-pole"]["status"] == get):
tile = "s-pole"
else:
ii = -8
@ -188,7 +188,7 @@ try:
name = ew + norm(abs(j), 3) + ns + norm(abs(i), 2)
if not name in status or (name in status and status[name]["status"] != "done"):
if not name in state or (name in state and state[name]["status"] != "done"):
if ns == "s":
ns_step = -1
else:
@ -204,7 +204,7 @@ try:
iii = abs(i)
for l in range(0, 10):
name_minor = ew + norm(j, 3) + ns + norm(iii, 2)
if not name in status or (not name_minor in status[name] or (name_minor in status[name] and (status[name][name_minor]["status"] == get))):
if not name in state or (not name_minor in state[name] or (name_minor in state[name] and (state[name][name_minor]["status"] == get))):
tile = name_minor
break
iii += ns_step

View file

@ -48,8 +48,8 @@ while i < argc:
print ("ERROR: Unknown action " + sys.argv[i])
sys.exit(1)
elif sys.argv[i] == "-h" or sys.argv[i] == "--help":
print("usage: build_chunk.py [OPTIONS]")
print("Runs a single chunk build. Mainly handles status logging")
print("usage:worldbuild-worker.py [OPTIONS]")
print("Retrives jobs from the manager and executes them")
print("")
print(" -p, --prefix Database prefix to use")
print(" --host Logger host")
@ -60,6 +60,7 @@ while i < argc:
print(" rebuild: Build tiles flaged for rebuild")
print(" skip: Force building tile that are marked for being skipped")
print(" -h, --help Shows this help and exit")
sys.exit(0)
else:
if first == 1:
first = 0
@ -110,7 +111,12 @@ def get_job(action):
ret = get_job(action)
return ret
def execute_build(name, prefix):
running = True
while running:
name = get_job(action)
try:
send_status(name, "started")
run("mkdir -p projects/worldbuild-" + name, shell=True)
@ -162,11 +168,20 @@ def execute_build(name, prefix):
if os.path.isfile("projects/worldbuild-" + name + "/osm2city-exceptions.log"):
run("mv projects/worldbuild-" + name + "/osm2city-exceptions.log projects/worldbuild/output/error/" + name + ".exceptions.log", shell=True)
sleep(10)
run("rm -rf projects/worldbuild-" + name, shell=True)
send_status(name, "done")
run = True:
while run:
tile = get_job(action)
execute_build(tile, prefix)
except KeyboardInterrupt:
print("Graceful shutdown triggered. To force immedate stop, press Ctrl+C again")
running = False
try:
build.wait()
except KeyboardInterrupt:
#TODO doesn't work
print("Forcing shutdown...")
build.terminate()
sleep(5)
build.kill()
sleep(5)
sys.exit(0)