mirror of
https://github.com/majmongoose/PageBot.git
synced 2026-08-27 14:06:26 -04:00
Update pagebot.py
This commit is contained in:
+10
-3
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user