2023-09-29 00:09:44 -06:00
|
|
|
import time
|
|
|
|
from threading import Thread
|
|
|
|
|
|
|
|
from llm_server import opts
|
|
|
|
from llm_server.cluster.worker import cluster_worker
|
2023-10-01 00:20:00 -06:00
|
|
|
from llm_server.routes.v1.generate_stats import generate_stats
|
2023-09-29 00:09:44 -06:00
|
|
|
from llm_server.workers.inferencer import start_workers
|
2023-10-04 19:24:47 -06:00
|
|
|
from llm_server.workers.logger import db_logger
|
2023-09-29 00:09:44 -06:00
|
|
|
from llm_server.workers.mainer import main_background_thread
|
|
|
|
from llm_server.workers.moderator import start_moderation_workers
|
|
|
|
from llm_server.workers.printer import console_printer
|
|
|
|
from llm_server.workers.recenter import recent_prompters_thread
|
|
|
|
|
|
|
|
|
|
|
|
def cache_stats():
|
|
|
|
while True:
|
|
|
|
generate_stats(regen=True)
|
2023-09-30 19:41:50 -06:00
|
|
|
time.sleep(5)
|
2023-09-29 00:09:44 -06:00
|
|
|
|
|
|
|
|
|
|
|
def start_background():
|
2023-10-05 21:37:18 -06:00
|
|
|
start_workers(opts.cluster)
|
2023-09-29 00:09:44 -06:00
|
|
|
|
|
|
|
t = Thread(target=main_background_thread)
|
|
|
|
t.daemon = True
|
|
|
|
t.start()
|
|
|
|
print('Started the main background thread.')
|
|
|
|
|
2023-10-03 13:40:08 -06:00
|
|
|
start_moderation_workers(opts.cluster_workers * 3)
|
2023-09-29 00:09:44 -06:00
|
|
|
|
|
|
|
t = Thread(target=cache_stats)
|
|
|
|
t.daemon = True
|
|
|
|
t.start()
|
|
|
|
print('Started the stats cacher.')
|
|
|
|
|
|
|
|
t = Thread(target=recent_prompters_thread)
|
|
|
|
t.daemon = True
|
|
|
|
t.start()
|
|
|
|
print('Started the recent proompters thread.')
|
|
|
|
|
|
|
|
t = Thread(target=console_printer)
|
|
|
|
t.daemon = True
|
|
|
|
t.start()
|
|
|
|
print('Started the console printer.')
|
|
|
|
|
|
|
|
t = Thread(target=cluster_worker)
|
|
|
|
t.daemon = True
|
|
|
|
t.start()
|
|
|
|
print('Started the cluster worker.')
|
2023-10-04 19:24:47 -06:00
|
|
|
|
|
|
|
t = Thread(target=db_logger)
|
|
|
|
t.daemon = True
|
|
|
|
t.start()
|
2023-10-05 17:00:35 -06:00
|
|
|
print('Started background logger.')
|