add port to the command options

This commit is contained in:
Noli 2022-03-25 22:18:28 +01:00
parent 076c6c8efa
commit 3e003d3b42
1 changed files with 13 additions and 9 deletions

View File

@ -725,6 +725,7 @@ parser = argparse.ArgumentParser(description="KoboldAI Server")
parser.add_argument("--remote", action='store_true', help="Optimizes KoboldAI for Remote Play")
parser.add_argument("--ngrok", action='store_true', help="Optimizes KoboldAI for Remote Play using Ngrok")
parser.add_argument("--host", action='store_true', help="Optimizes KoboldAI for Remote Play without using a proxy service")
parser.add_argument("--port", type=int, help="Specify the port on which the application will be joinable")
parser.add_argument("--model", help="Specify the Model Type to skip the Menu")
parser.add_argument("--path", help="Specify the Path for local models (For model NeoCustom or GPT2Custom)")
parser.add_argument("--cpu", action='store_true', help="By default unattended launches are on the GPU use this option to force CPU usage.")
@ -5185,6 +5186,7 @@ def send_debug():
#==================================================================#
print("", end="", flush=True)
if __name__ == "__main__":
port = args.port if "port" in args else 5000
print("{0}\nStarting webserver...{1}".format(colors.GREEN, colors.END), flush=True)
# Start Flask/SocketIO (Blocking, so this must be last method!)
@ -5196,24 +5198,26 @@ if __name__ == "__main__":
cloudflare = _run_ngrok()
elif(args.remote):
from flask_cloudflared import _run_cloudflared
cloudflare = _run_cloudflared(5000)
cloudflare = _run_cloudflared(port)
if(args.ngrok or args.remote):
with open('cloudflare.log', 'w') as cloudflarelog:
cloudflarelog.write("KoboldAI has finished loading and is available at the following link : " + cloudflare)
print(format(colors.GREEN) + "KoboldAI has finished loading and is available at the following link : " + cloudflare + format(colors.END))
else:
print("{0}Webserver has started, you can now connect to this machine at port 5000{1}".format(colors.GREEN, colors.END))
print("{0}Webserver has started, you can now connect to this machine at port 5000{1}"
.format(colors.GREEN, colors.END))
vars.serverstarted = True
socketio.run(app, host='0.0.0.0', port=5000)
socketio.run(app, host='0.0.0.0', port=port)
else:
import webbrowser
webbrowser.open_new('http://localhost:5000')
print("{0}Server started!\nYou may now connect with a browser at http://127.0.0.1:5000/{1}".format(colors.GREEN, colors.END))
webbrowser.open_new('http://localhost:{0}'.format(port))
print("{0}Server started!\nYou may now connect with a browser at http://127.0.0.1:{1}/{2}"
.format(colors.GREEN, port, colors.END))
vars.serverstarted = True
if args.unblock:
socketio.run(app, port=5000, host='0.0.0.0')
socketio.run(app, port=port, host='0.0.0.0')
else:
socketio.run(app, port=5000)
socketio.run(app, port=port)
else:
print("{0}\nServer started in WSGI mode!{1}".format(colors.GREEN, colors.END), flush=True)