2023-09-28 18:40:24 -06:00
|
|
|
try:
|
|
|
|
import gevent.monkey
|
|
|
|
|
|
|
|
gevent.monkey.patch_all()
|
|
|
|
except ImportError:
|
|
|
|
pass
|
|
|
|
|
|
|
|
import time
|
|
|
|
from threading import Thread
|
2023-09-29 00:09:44 -06:00
|
|
|
from llm_server.cluster.redis_cycle import load_backend_cycle
|
2023-09-28 18:40:24 -06:00
|
|
|
|
2023-09-29 00:09:44 -06:00
|
|
|
from llm_server.cluster.backend import get_backends, get_a_cluster_backend
|
2023-09-28 18:40:24 -06:00
|
|
|
from llm_server.cluster.worker import cluster_worker
|
|
|
|
from llm_server.config.load import parse_backends, load_config
|
2023-09-29 00:09:44 -06:00
|
|
|
from llm_server.cluster.redis_config_cache import RedisClusterStore
|
|
|
|
|
|
|
|
import argparse
|
|
|
|
|
|
|
|
parser = argparse.ArgumentParser()
|
|
|
|
parser.add_argument('config')
|
|
|
|
args = parser.parse_args()
|
2023-09-28 18:40:24 -06:00
|
|
|
|
2023-09-29 00:09:44 -06:00
|
|
|
success, config, msg = load_config(args.config)
|
2023-09-28 18:40:24 -06:00
|
|
|
|
|
|
|
cluster_config = RedisClusterStore('cluster_config')
|
|
|
|
cluster_config.clear()
|
|
|
|
cluster_config.load(parse_backends(config))
|
2023-09-29 00:09:44 -06:00
|
|
|
on, off = get_backends()
|
|
|
|
load_backend_cycle('backend_cycler', on + off)
|
2023-09-28 18:40:24 -06:00
|
|
|
|
|
|
|
t = Thread(target=cluster_worker)
|
|
|
|
t.daemon = True
|
|
|
|
t.start()
|
|
|
|
|
|
|
|
while True:
|
2023-09-29 00:09:44 -06:00
|
|
|
# online, offline = get_backends()
|
|
|
|
# print(online, offline)
|
|
|
|
# print(get_a_cluster_backend())
|
2023-09-28 18:40:24 -06:00
|
|
|
time.sleep(3)
|