🎨 修改core重启的方式

This commit is contained in:
KimigaiiWuyi 2025-06-09 17:19:39 +08:00
parent f3882ca6eb
commit ebea4e4197

View File

@ -29,9 +29,15 @@ def get_restart_command():
return restart_command return restart_command
else: else:
tool = check_start_tool() tool = check_start_tool()
if tool != 'python': if tool == 'uv':
return f'{tool} run python' return 'uv run core'
return 'python' elif tool == 'pdm':
return 'pdm run core'
elif tool == 'poetry':
return 'poetry run core'
elif tool == 'python':
return 'python -m gsuid_core.core'
return 'python -m gsuid_core.core'
async def get_restart_sh() -> str: async def get_restart_sh() -> str:
@ -52,8 +58,10 @@ async def restart_genshinuid(
with open(restart_sh_path, "w", encoding="utf8") as f: with open(restart_sh_path, "w", encoding="utf8") as f:
f.write(restart_sh) f.write(restart_sh)
if platform.system() == 'Linux': if platform.system() == 'Linux':
os.system(f'chmod +x {str(restart_sh_path)}') # os.system(f'chmod +x {str(restart_sh_path)}')
os.system(f'chmod +x {str(bot_start)}') # os.system(f'chmod +x {str(bot_start)}')
pass
now_time = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time())) now_time = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time()))
if is_send: if is_send:
update_log = { update_log = {
@ -69,12 +77,12 @@ async def restart_genshinuid(
json.dump(update_log, f) json.dump(update_log, f)
if platform.system() == 'Linux': if platform.system() == 'Linux':
subprocess.Popen( subprocess.Popen(
f'kill -9 {pid} & {get_restart_command()} {bot_start}', f'kill -9 {pid} & {get_restart_command()}',
shell=True, shell=True,
) )
else: else:
subprocess.Popen( subprocess.Popen(
f'taskkill /F /PID {pid} & {get_restart_command()} {bot_start}', f'taskkill /F /PID {pid} & {get_restart_command()}',
shell=True, shell=True,
) )