Update pagebot.py

This commit is contained in:
majmongoose
2026-08-21 11:39:24 -04:00
parent 9ec20afbaf
commit 0ac3261f97
+10 -3
View File
@@ -112,6 +112,13 @@ async def upload_to_discord(mp4_file, text):
TTD_TIMEOUT = getattr(secrets_file, 'ttd_timeout', 900)
def kill_process_tree(pid):
try:
subprocess.run(['taskkill', '/F', '/T', '/PID', str(pid)],
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
except Exception as e:
print(f"Error killing process tree: {e}")
def launch_and_watch(program_path):
global last_file_time
program_directory = os.path.dirname(program_path)
@@ -125,11 +132,11 @@ def launch_and_watch(program_path):
except subprocess.TimeoutExpired:
if time.time() - last_file_time > TTD_TIMEOUT:
print("TTD appears to have locked up (no new files in 15 minutes). Restarting...")
process.kill()
process.wait()
kill_process_tree(process.pid)
break
if process.returncode != 0:
if process.returncode is None or process.returncode != 0:
print("TTD has crashed. Relaunching...")
kill_process_tree(process.pid)
else:
print("TTD has exited normally.")
break