mirror of
https://github.com/majmongoose/PageBot.git
synced 2025-06-27 23:45:15 -04:00
more attempts
This commit is contained in:
parent
83fe6387e9
commit
94423eaa9a
10
pagebot.py
10
pagebot.py
@ -93,8 +93,6 @@ async def upload_to_discord(mp4_file,text):
|
|||||||
else:
|
else:
|
||||||
print(f"Could not find channel with ID {channel}")
|
print(f"Could not find channel with ID {channel}")
|
||||||
|
|
||||||
from datetime import datetime
|
|
||||||
|
|
||||||
|
|
||||||
def launch_and_watch(program_path):
|
def launch_and_watch(program_path):
|
||||||
program_directory = os.path.dirname(program_path)
|
program_directory = os.path.dirname(program_path)
|
||||||
@ -104,8 +102,15 @@ def launch_and_watch(program_path):
|
|||||||
restart_hour, restart_minute = map(int, restart_time.split(":"))
|
restart_hour, restart_minute = map(int, restart_time.split(":"))
|
||||||
|
|
||||||
restart_triggered = False # Flag to prevent multiple restarts within the same minute
|
restart_triggered = False # Flag to prevent multiple restarts within the same minute
|
||||||
|
process = None # Initialize the process variable outside the loop
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
|
# If a process is already running, terminate it before starting a new one
|
||||||
|
if process and process.poll() is None:
|
||||||
|
print("Terminating the existing TTD process before restarting...")
|
||||||
|
process.terminate()
|
||||||
|
process.wait()
|
||||||
|
|
||||||
# Launch the TTD program
|
# Launch the TTD program
|
||||||
print("Starting TTD program...")
|
print("Starting TTD program...")
|
||||||
process = subprocess.Popen(program_path, cwd=program_directory)
|
process = subprocess.Popen(program_path, cwd=program_directory)
|
||||||
@ -138,6 +143,7 @@ def launch_and_watch(program_path):
|
|||||||
print("Waiting before relaunching TTD...")
|
print("Waiting before relaunching TTD...")
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
||||||
## initialize watchdogs
|
## initialize watchdogs
|
||||||
|
Loading…
x
Reference in New Issue
Block a user