From aa9785da5a276402e055d03ca9e6d4c63aff173b Mon Sep 17 00:00:00 2001 From: jenz Date: Thu, 5 Jun 2025 23:46:59 +0200 Subject: [PATCH] handling cpu limiting differently, maybe fine --- AutismBotIngame/README.md | 5 ++--- AutismBotIngame/python/ingamefollowct.py | 20 ++++++++------------ 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/AutismBotIngame/README.md b/AutismBotIngame/README.md index 58a3377..f54a771 100644 --- a/AutismBotIngame/README.md +++ b/AutismBotIngame/README.md @@ -35,11 +35,9 @@ /home/gameservers/.steam/debian-installation/steamapps/common/Counter-Strike Source/cstrike/cfg/autoexec.cfg:
alias loop "exec looptest.cfg; wait 5; loop;"; wait 5; loop;
- (textmode is no video output)
exporting correct SDL_VIDEO_X11_VISUALID value is important before steam login for starting games correctly

With the virtual desktop related to the VNC/x2go/nomachine client you can log into steam using the normal GUI ->
- once logged in steam can run actively for months without requiring restarts ## bashrc for users in the users thats running a session edit the .bashrc file and add the follwing (remember SDL_VIDEO_X11_VISUALID deppends on glxinfo from xterm terminal): @@ -52,7 +50,7 @@ fi - ovh: 0x205, 0x209 + 0x205, 0x209 #if running steam native libraries instead of runtime libraries one might require following apt install for making libpipewire work @@ -90,3 +88,4 @@ limiting cpu can throttle the download speed as well. if bots cant connect and a #pip3 extra pip3 install watchdog + diff --git a/AutismBotIngame/python/ingamefollowct.py b/AutismBotIngame/python/ingamefollowct.py index a1e9ac8..2a88f14 100644 --- a/AutismBotIngame/python/ingamefollowct.py +++ b/AutismBotIngame/python/ingamefollowct.py @@ -164,17 +164,16 @@ def bot_connect(data): #use whatever ip you want here to connect with str1 = "" if "connect to ze" == data: - str1 = f"connect {data_ports['server_ip_port_ze']}" + str1 = f"connect {data_ports['server_ip_port_ze']};" elif "connect to ze2" == data: - str1 = f"connect {data_ports['server_ip_port_ze2']}; wait 15000;" + str1 = f"connect {data_ports['server_ip_port_ze2']};" #wait 15000; writeCfgInput(str1) - time.sleep(1) def cpulimit_pid_of_game(): # ' > /dev/null' redirects stdout to /dev/null # '2>&1' redirects stderr to the same place as stdout pid = return_user_owned_pid("pidof cstrike_linux64") - cmd = f"cpulimit --pid={pid} --limit=5 --background > /dev/null 2>&1" + cmd = f"cpulimit --pid={pid} --limit=35 --background > /dev/null 2>&1" subprocess.Popen([cmd], shell=True, stdout=subprocess.PIPE).communicate()[0] def delete_lock_file(): @@ -188,10 +187,7 @@ def my_file_created_function(event_path): file_size = None while True: - #repeatedly spamming to kill cpu limitting, its bottlenecking the download speed - kill_owned_process("pidof cpulimit") time.sleep(10) - stdout, stderr = subprocess.Popen(["ls", "-l", event_path], stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate() #print('stdout: ', stdout) #print('stderr: ', stderr) @@ -206,6 +202,7 @@ def my_file_created_function(event_path): #in case the bz2 download is not progressing just delete the file and disconnect. cur_file_size = stdout.decode().split("autismbots")[1].strip().split(" ")[0] + print('cur_file_size: ', cur_file_size, ' stdout decode: ', stdout.decode()) if file_size == cur_file_size: print("Aborting connection. file download is stuck.") writeCfgInput("disconnect;") @@ -265,6 +262,7 @@ if __name__ == '__main__': print("launching game...") fail_safe -= 1 time.sleep(10) + cpulimit_pid_of_game() try: while True: @@ -297,14 +295,14 @@ if __name__ == '__main__': print('bot kicked server full: ', datetime.datetime.now().time()) elif "autismo connected to ze" == data: print('Bot connected to ze!') - cpulimit_pid_of_game() + #cpulimit_pid_of_game() is_bot_connected_to_ze2 = False overwrite_file_access() elif "not connected to ze2" == data: is_bot_connected_to_ze2 = False elif "autismo connected to ze2" == data: print('Bot connected to ze2!') - cpulimit_pid_of_game() + #cpulimit_pid_of_game() is_bot_connected_to_ze2 = True overwrite_file_access() elif "connect to ze" == data or ("connect to ze2" == data and not is_bot_connected_to_ze2): @@ -315,9 +313,7 @@ if __name__ == '__main__': print('exiting after running the game for several hours.') sys.exit(1) else: - #stop cpu limitting, its bottlenecking the connection to the server. - kill_owned_process("pidof cpulimit") - #print('data: ', data) + print('data: ', data) bot_connect(data) elif "clientmessage:" in data: messager_name = data.split("clientmessage:", 1)[1].split(f" {data_ports['magic_secret']}")[0]