Make uncloud host running

This commit is contained in:
Nico Schottelius 2019-12-31 14:06:51 +01:00
parent 9662e02eb7
commit e775570884
2 changed files with 19 additions and 5 deletions

View file

@ -590,11 +590,10 @@ def main(debug=False, port=None):
# json.dumps(data),
# )
if port:
app_port = port
try:
app.run(host="::", debug=False)
app.run(host="::",
port=port,
debug=debug)
except OSError as e:
raise UncloudException("Failed to start Flask: {}".format(e))

View file

@ -1,6 +1,7 @@
import argparse
import multiprocessing as mp
import time
from uuid import uuid4
from uncloud.common.request import RequestEntry, RequestType
from uncloud.shared import shared
@ -42,7 +43,21 @@ def maintenance(host):
def main(hostname):
host_pool = shared.host_pool
host = next(filter(lambda h: h.hostname == hostname, host_pool.hosts), None)
assert host is not None, "No such host with name = {}".format(hostname)
# Does not yet exist, create it
if not host:
host_key = join_path(
settings["etcd"]["host_prefix"], uuid4().hex
)
host_entry = {
"specs": "",
"hostname": hostname,
"status": "DEAD",
"last_heartbeat": "",
}
shared.etcd_client.put(
host_key, host_entry, value_in_json=True
)
try:
heartbeat_updating_process = mp.Process(target=update_heartbeat, args=(hostname,))