added socket close when exiting. added pkill to users pid to clear /dev/shm. added exit post program to kill with pkill again due to atexit handler not responding to signals from outside python
This commit is contained in:
parent
5005985ce3
commit
6d91f50133
9
AutismBotIngame/python/exit_handler.py
Normal file
9
AutismBotIngame/python/exit_handler.py
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
#!/home/autismbot1/ze_runner/venv/bin/python3
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
import subprocess
|
||||||
|
#deleting POSIX shared memory objects, as long as one process has them open they exist. THis is to prevent /dev/shm from being full
|
||||||
|
#due to steam child processes.
|
||||||
|
#even with steam turned offline might there be chromium web browsers left over from steam who still hold processes open.
|
||||||
|
#only kind of potential issues from this is steam cloud being out of sync, which is really fucking irrelevant.
|
||||||
|
subprocess.getoutput([f"pkill -9 -u {whoami}"])
|
@ -35,6 +35,11 @@ def exit_handler():
|
|||||||
#securing the looptest.cfg wont be stuck accidently with commands
|
#securing the looptest.cfg wont be stuck accidently with commands
|
||||||
kill_owned_process("pidof hl2_linux")
|
kill_owned_process("pidof hl2_linux")
|
||||||
kill_owned_process("pidof xterm")
|
kill_owned_process("pidof xterm")
|
||||||
|
#deleting POSIX shared memory objects, as long as one process has them open they exist. THis is to prevent /dev/shm from being full
|
||||||
|
#due to steam child processes.
|
||||||
|
#even with steam turned offline might there be chromium web browsers left over from steam who still hold processes open.
|
||||||
|
#only kind of potential issues from this is steam cloud being out of sync, which is really fucking irrelevant.
|
||||||
|
subprocess.getoutput([f"pkill -9 -u {whoami}"])
|
||||||
|
|
||||||
def bot_process_movement(input_line):
|
def bot_process_movement(input_line):
|
||||||
dist_target = input_line[input_line.index("dist_target:") + len("dist_target:"):input_line.index("enemy_distance")]
|
dist_target = input_line[input_line.index("dist_target:") + len("dist_target:"):input_line.index("enemy_distance")]
|
||||||
@ -178,10 +183,6 @@ if __name__ == '__main__':
|
|||||||
if maps_folder_size > 40.0:
|
if maps_folder_size > 40.0:
|
||||||
for f in glob.glob(f"/home/{whoami}/.steam/debian-installation/steamapps/common/Counter-Strike Source/cstrike/download/maps/*"):
|
for f in glob.glob(f"/home/{whoami}/.steam/debian-installation/steamapps/common/Counter-Strike Source/cstrike/download/maps/*"):
|
||||||
subprocess.Popen(["rm", f], stdout=subprocess.PIPE).communicate()[0]
|
subprocess.Popen(["rm", f], stdout=subprocess.PIPE).communicate()[0]
|
||||||
#deleting POSIX shared memory objects, as long as one process has them open they exist. so probably until steam gets turned off. THis is to prevent /dev/shm from being full
|
|
||||||
#subprocess.getoutput([f"rm /dev/shm/u1001-Shm_*"])
|
|
||||||
#subprocess.getoutput([f"rm /dev/shm/u1002-Shm_*"])
|
|
||||||
#NOTE since not running vm's anymore i quit doing this. instead just restarting the service every 10 hours.
|
|
||||||
restart_sdl_and_steam()
|
restart_sdl_and_steam()
|
||||||
is_bot_connected_to_ze2 = False
|
is_bot_connected_to_ze2 = False
|
||||||
|
|
||||||
@ -233,6 +234,7 @@ if __name__ == '__main__':
|
|||||||
if connection_issue_counter == 5:
|
if connection_issue_counter == 5:
|
||||||
kill_owned_process("pidof hl2_linux")
|
kill_owned_process("pidof hl2_linux")
|
||||||
print('exiting')
|
print('exiting')
|
||||||
|
sock.close()
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
else:
|
else:
|
||||||
if call_bot_connect:
|
if call_bot_connect:
|
||||||
|
Loading…
Reference in New Issue
Block a user