Add sandero Profile + Start_server handling + Add proc_type_validator fn

main
Alex 5 months ago
parent 663f2889d4
commit 9728d21674

@ -94,10 +94,20 @@ gaming_server_profiles = {
'exec_path': "C:/Users/4lexK/Desktop/GameServers/Ragnarok Online/SanderRo_rathena/2 . Emulator/rathena", # Path zur Rathena Installation
'server_name': 'SanderRO',
'directory': "C:/Users/4lexK/Desktop/GameServers/Ragnarok Online/SanderRo_rathena",
'args_asgard': "",
'args_midgar': "",
'args_svartalfeim': "",
'wait_time': 30
'wait_time': 30,
'cmd_map': "",
'cmd_web': "",
# Realms
# Asgard -> Low Rates (HardMode/Oldschool/"Vanilla")
'cmd_asgard_char': "",
'cmd_asgard_login': "",
# Midgard -> Mid Rates (NormalMode)
'cmd_midgard_char': "",
'cmd_midgard_login': "",
# Svartalfheim -> High Rates (EasyMode/TestingGround)
'cmd_svartalfeim_char': "",
'cmd_svartalfheim_login': ""
}
# World of Warcraft
}
@ -380,20 +390,42 @@ def start_gameserver(profile: str) -> str:
case "exe_ro":
# Bei exe von Ragnarok Online werden immer mehrere Server gestartet da verschiedene Server
# unterschiedliche Aufgaben haben und zusammen arbeiten (je nach dem wie viele Realms eingebaut sind | zur Zeit [08/2024] 3)
os.chdir(server['directory'])
# Es wird immer Map- und Web-Server Basis gestartet. Hinzu kommt jeweils ein Char- und ein Login-Server pro Realm (z.Zt [08/2024] 3)
# Note: Es wird immer Map- und Web-Server Basis gestartet. Hinzu kommt jeweils ein Char- und ein Login-Server pro Realm (z.Zt [08/2024] 3)
os.chdir(server['directory'])
# Map-Server
pid_file_map = os.path.join(server['directory'], f'{server['srv_map_name']}.pid')
log_file_map = os.path.join(server['directory'], 'logs', f'server_{server['srv_map_name']}_{datetime.now().strftime("%Y%m%d_%H%M%S")}.log')
pid_file_map = os.path.join(server['directory'], f'{server['server_name']}_map.pid')
log_file_map = os.path.join(server['directory'], 'logs', f'server_{server['server_name']}_map_{datetime.now().strftime("%Y%m%d_%H%M%S")}.log')
os.makedirs(os.path.dirname(log_file_map), exist_ok=True)
# Prüfen, ob Prozesse bereits laufen
response = initialize_pid(pid_file_map, f"{server['server_name']} (Map-Server)", is_ro_process)
response_msg += response
# Starten des Prozess
pid = start_process(log_file_map, command=server[f"cmd_map"], cur_wrk_dir=server['directory'])
with open(pid_file_web, 'w') as file:
file.write(str(pid))
response_msg += f"Server {server['server_name']} (Map-Server) wurde mit PID '{pid}' gestartet. "
# Web-Server
pid_file_web = os.path.join(server['directory'], f'{server['srv_web_name']}.pid')
log_file_web = os.path.join(server['directory'], 'logs', f'server_{server['srv_web_name']}_{datetime.now().strftime("%Y%m%d_%H%M%S")}.log')
os.makedirs(os.path.dirname(log_file_map), exist_ok=True)
# Prüfen, ob Prozesse bereits laufen
response = initialize_pid(pid_file_web, f"{server['server_name']} (Web-Server)", is_ro_process)
response_msg += response
# Starten des Prozess
pid = start_process(log_file_web, command=server[f"cmd_web"], cur_wrk_dir=server['directory'])
with open(pid_file_web, 'w') as file:
file.write(str(pid))
response_msg += f"Server {server['server_name']} (Web-Server) wurde mit PID '{pid}' gestartet. "
# TODO Realms fertig bauen
# Realm Server
realm_names = server['realm_names']
for realm in realm_names:
@ -551,6 +583,15 @@ def is_dst_process(pid):
return False
except psutil.NoSuchProcess:
return False
def is_ro_process(pid):
try:
p = psutil.Process(pid)
#return 'java' in p.name().lower()
print(p.name())
return True
except psutil.NoSuchProcess:
return False
# Function to send the main menu
async def send_main_menu(context: ContextTypes.DEFAULT_TYPE, chat_id: int):

Loading…
Cancel
Save