extras_server in separate file like models

This commit is contained in:
Alexey Dashko
2023-04-07 01:00:09 +03:00
parent e4c9bf05cb
commit 80eadabfa2
3 changed files with 142 additions and 110 deletions

35
colab/extras_server.py Normal file
View File

@ -0,0 +1,35 @@
import os, time, subprocess
def runServer():
cmd = f"python server.py {' '.join(params)}"
print(cmd)
extras_process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, cwd='/TavernAI-extras', shell=True)
print('processId:', extras_process.pid)
while True:
line = extras_process.stdout.readline().decode().strip()
if "Running on " in line:
break
if not line:
print('breaking on line')
break
print(line)
def extractUrl():
subprocess.call('nohup lt --port 5100 > ./extras.out 2> ./extras.err &', shell=True)
print('Waiting for lt init...')
while True:
if (os.path.getsize('./extras.out') > 0):
with open('./extras.out', 'r') as f:
lines = f.readlines()
for x in range(len(lines)):
if ('your url is: ' in lines[x]):
print('TavernAI Extensions URL:')
extras_url = lines[x].split('your url is: ')[1]
print(extras_url)
break
if (os.path.getsize('./extras.err') > 0):
with open('./extras.err', 'r') as f:
print(f.readlines())
break
time.sleep(1)