Files
palworld_tools/serverRestart.py
2024-01-29 01:36:31 +00:00

70 lines
2.1 KiB
Python
Executable File

import time
import subprocess
import os
def fiveMinWarning():
print("Sending 5 minute Warning")
subprocess.call("ARRCON -H 192.168.0.190 -P 25575 -p bXe37GbFn08rWrOzaLAI -f 5min.txt", shell=True)
def fourMinWarning():
print("Sending 4 minute Warning")
subprocess.call("ARRCON -H 192.168.0.190 -P 25575 -p bXe37GbFn08rWrOzaLAI -f 4min.txt", shell=True)
def threeMinWarning():
print("Sending 3 minute Warning")
subprocess.call("ARRCON -H 192.168.0.190 -P 25575 -p bXe37GbFn08rWrOzaLAI -f 3min.txt", shell=True)
def twoMinWarning():
print("Sending 2 minute Warning")
subprocess.call("ARRCON -H 192.168.0.190 -P 25575 -p bXe37GbFn08rWrOzaLAI -f 2min.txt", shell=True)
def oneMinWarning():
print("Sending 1 minute Warning")
subprocess.call("ARRCON -H 192.168.0.190 -P 25575 -p bXe37GbFn08rWrOzaLAI -f 1min.txt", shell=True)
def tenSecWarning():
print("Sending 10 sec warning")
subprocess.call("ARRCON -H 192.168.0.190 -P 25575 -p bXe37GbFn08rWrOzaLAI -f 10sec.txt", shell=True)
time.sleep(10)
restartServer()
def restartServer():
subprocess.call("docker container restart palworld-server", shell=True)
import time
def timer(duration, interval, statements):
start_time = time.time()
next_statement_time = start_time + interval
statement_index = 0
isRunning = True
while time.time() - start_time < duration:
if time.time() >= next_statement_time:
if statement_index < len(statements):
calledFunction = statements[statement_index]
result = calledFunction()
statement_index += 1
next_statement_time += interval
else:
print("Complete")
break
time.sleep(0.1) # Adjust the sleep time to reduce CPU usage
# Example usage
duration = 500 # Duration of the timer in seconds
interval = 60 # Interval between statements in seconds
statements = [
fiveMinWarning,
fourMinWarning,
threeMinWarning,
twoMinWarning,
oneMinWarning,
tenSecWarning
]
timer(duration, interval, statements)