mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
extras_server in separate file like models
This commit is contained in:
35
colab/extras_server.py
Normal file
35
colab/extras_server.py
Normal 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)
|
Reference in New Issue
Block a user