change singleinstance order

This commit is contained in:
Concedo 2025-06-06 21:20:30 +08:00
parent d18938fc70
commit 6effb65cfe
3 changed files with 19 additions and 14 deletions

View file

@ -51,9 +51,6 @@ jobs:
run: |
./koboldcpp.sh dist
- name: Rename file before upload
run: mv dist/koboldcpp-linux-x64-cuda1240 dist/koboldcpp-linux-x64-cuda12
- name: Save artifact
uses: actions/upload-artifact@v4
with:

View file

@ -23964,8 +23964,11 @@ Current version indicated by LITEVER below.
<option value="2">2x</option>
<option value="3">3x</option>
<option value="5">5x</option>
<option value="8">8x</option>
<option value="10">10x</option>
<option value="15">15x</option>
<option value="20">20x</option>
<option value="30">30x</option>
<option value="50">50x</option>
</select>
<select title="Idle Responses Duration" style="padding:1px; height:auto; width: 27px; appearance: none; font-size: 7pt;" class="form-control" id="idle_duration">
<option value="5">5s</option>

View file

@ -3812,13 +3812,6 @@ def RunServerMultiThreaded(addr, port, server_handler):
global embedded_kailite, embedded_kcpp_docs, embedded_kcpp_sdui, global_memory
if is_port_in_use(port):
print(f"Warning: Port {port} already appears to be in use by another program.")
if args.singleinstance:
print(f"Attempting to request shutdown of previous instance on port {port}...")
shutdownreq = make_url_request(f'http://localhost:{port}/api/extra/shutdown',{})
shutdownok = (shutdownreq and "success" in shutdownreq and shutdownreq["success"] is True)
time.sleep(2)
print("Shutdown existing successful!" if shutdownok else "Shutdown existing failed!")
time.sleep(1)
ipv4_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
ipv4_sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
@ -6536,6 +6529,21 @@ def kcpp_main_process(launch_args, g_memory=None, gui_launcher=False):
args.defaultgenamt = max(128, min(args.defaultgenamt, 4096))
args.defaultgenamt = min(args.defaultgenamt, maxctx / 2)
if args.port_param!=defaultport:
args.port = args.port_param
if start_server and args.singleinstance and is_port_in_use(args.port):
try:
print(f"Warning: Port {args.port} already appears to be in use by another program.")
print(f"Attempting to request shutdown of previous instance on port {args.port}...")
shutdownreq = make_url_request(f'http://localhost:{args.port}/api/extra/shutdown',{},timeout=5)
shutdownok = (shutdownreq and "success" in shutdownreq and shutdownreq["success"] is True)
time.sleep(2)
print("Shutdown existing successful!" if shutdownok else "Shutdown existing failed!")
time.sleep(1)
except Exception:
pass
if args.nocertify:
import ssl
global nocertify
@ -6839,9 +6847,6 @@ def kcpp_main_process(launch_args, g_memory=None, gui_launcher=False):
print(f"Inactive Modules: {' '.join(disabledmlist)}")
print(f"Enabled APIs: {' '.join(apimlist)}")
if args.port_param!=defaultport:
args.port = args.port_param
global sslvalid
if args.ssl:
if len(args.ssl)==2 and isinstance(args.ssl[0], str) and os.path.exists(args.ssl[0]) and isinstance(args.ssl[1], str) and os.path.exists(args.ssl[1]):