further file cleanup added
This commit is contained in:
		
							parent
							
								
									a2eb7ade88
								
							
						
					
					
						commit
						44cd674f49
					
				@ -31,6 +31,19 @@ def writeCfgInput(Input_user):
 | 
			
		||||
    #time.sleep(10.0)
 | 
			
		||||
    time.sleep(0.1)
 | 
			
		||||
 | 
			
		||||
def clean_up_files():
 | 
			
		||||
    #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.Popen(["rm -rf /tmp/steam*"], shell=True, stdout=subprocess.PIPE).communicate()[0]
 | 
			
		||||
    subprocess.Popen(["rm -rf /tmp/dbus*"], shell=True, stdout=subprocess.PIPE).communicate()[0]
 | 
			
		||||
    subprocess.Popen(["rm -rf /tmp/pressure*"], shell=True, stdout=subprocess.PIPE).communicate()[0]
 | 
			
		||||
    subprocess.Popen(["rm -rf /tmp/tigervnc*"], shell=True, stdout=subprocess.PIPE).communicate()[0]
 | 
			
		||||
    subprocess.Popen(["rm -rf /tmp/dumps*"], shell=True, stdout=subprocess.PIPE).communicate()[0]
 | 
			
		||||
    subprocess.Popen(["rm -rf /dev/shm/u100*"], shell=True, stdout=subprocess.PIPE).communicate()[0] 
 | 
			
		||||
    #users should only have permissions to delete their own files probably
 | 
			
		||||
 | 
			
		||||
def exit_handler():
 | 
			
		||||
    print('reached exithandler')
 | 
			
		||||
    writeCfgInput('')
 | 
			
		||||
@ -38,10 +51,7 @@ def exit_handler():
 | 
			
		||||
    kill_owned_process("pidof cstrike_linux64")
 | 
			
		||||
    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. 
 | 
			
		||||
    clean_up_files()
 | 
			
		||||
    subprocess.getoutput([f"pkill -9 -u {whoami}"])
 | 
			
		||||
 | 
			
		||||
def bot_process_movement(input_line):
 | 
			
		||||
@ -116,6 +126,7 @@ def restart_sdl_and_steam():
 | 
			
		||||
    subprocess.getoutput([f'vncserver -kill']) #only displays vncservers for the specific user.
 | 
			
		||||
    time.sleep(5)
 | 
			
		||||
    
 | 
			
		||||
    #cmd = f'vncserver -localhost no -geometry 1x1 -depth 24'
 | 
			
		||||
    cmd = f'vncserver -localhost no -geometry 1x1 -depth 24'
 | 
			
		||||
    print(f'cmd: {cmd}')
 | 
			
		||||
    subprocess.getoutput([cmd])
 | 
			
		||||
@ -142,7 +153,7 @@ def cpulimit_pid_of_game():
 | 
			
		||||
    #print('the command is: ', cmd)
 | 
			
		||||
    subprocess.Popen([cmd], shell=True, stdout=subprocess.PIPE).communicate()[0]
 | 
			
		||||
 | 
			
		||||
def delete_tmp_leftovers():
 | 
			
		||||
def delete_lock_file():
 | 
			
		||||
    #just delete the tmp source_engine .lock file here so multiple instances can run at same time.
 | 
			
		||||
    subprocess.Popen(["rm -f /tmp/source_engine*.lock"], shell=True, stdout=subprocess.PIPE).communicate()[0]
 | 
			
		||||
 | 
			
		||||
@ -159,6 +170,8 @@ if __name__ == '__main__':
 | 
			
		||||
    external_port_messages = data_ports['chat_external_port']
 | 
			
		||||
    buffer_size = 4096 #potentially not large enough?
 | 
			
		||||
 | 
			
		||||
    clean_up_files()
 | 
			
		||||
    delete_lock_file()
 | 
			
		||||
    #if downloading maps we give it 10 seconds delay to see if the size changed, if not its probably safe to delete the .bz2 file as no download in progress
 | 
			
		||||
    bz2_maps = {}
 | 
			
		||||
    while True:
 | 
			
		||||
@ -195,7 +208,7 @@ if __name__ == '__main__':
 | 
			
		||||
    sock.settimeout(5.0)
 | 
			
		||||
    messager_name = ""
 | 
			
		||||
 | 
			
		||||
    t = Timer(10, delete_tmp_leftovers)
 | 
			
		||||
    t = Timer(10, delete_lock_file)
 | 
			
		||||
    t.start()
 | 
			
		||||
 | 
			
		||||
    #limit the cpu allowed to be used by the game instance.
 | 
			
		||||
@ -253,8 +266,8 @@ if __name__ == '__main__':
 | 
			
		||||
                        print("connection_issue_counter: ", connection_issue_counter)
 | 
			
		||||
                        bot_connect(data)
 | 
			
		||||
            elif "clientmessage:" in data:
 | 
			
		||||
                messager_name = data.split("clientmessage:", 1)[1].split(" secret_code_here")[0]
 | 
			
		||||
                databyte_send_message = messager_name + data.split("secret_code_here")[1]
 | 
			
		||||
                messager_name = data.split("clientmessage:", 1)[1].split("magic_code_here")[0]
 | 
			
		||||
                databyte_send_message = messager_name + data.split("magic_code_here")[1]
 | 
			
		||||
                sock.sendto(databyte_send_message.encode(), (data_ports["discord_bot_ip"], external_port_messages))
 | 
			
		||||
                #print('databyte_send_message: ', databyte_send_message)
 | 
			
		||||
            elif data.startswith("dist_target:"):
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user