- Joined
- Feb 14, 2015
- Messages
- 5,643
- Solutions
- 559
- Reaction score
- 3,949
Requirements: Python 3.5, psutil package (use pip install psutil to install)
Instructions: Copy the below code into a new python script and save it to the same directory where your server executable is located
Instructions: Copy the below code into a new python script and save it to the same directory where your server executable is located
Python:
import psutil # DEPENDENCY: pip install psutil
import os
import time
from threading import Timer
PROCESS_NAME = "theforgottenserver.exe"
CHECK_INTERVAL = 3.0
def process_exists():
for process in psutil.process_iter():
if process.name() == PROCESS_NAME:
return True
return False
def check_server():
if not process_exists():
os.startfile(PROCESS_NAME)
timestamp = time.strftime("%a, %d %b %H:%M:%S", time.localtime())
print("{} | Notice: {} started (process not found)".format(timestamp, PROCESS_NAME))
timer = Timer(CHECK_INTERVAL, check_server)
timer.start()
check_server()