From c2a673dfc37997df401d2b5fea437340a4762168 Mon Sep 17 00:00:00 2001 From: Andrew McManus Date: Fri, 30 Jul 2021 10:30:58 -0400 Subject: [PATCH] Added Try Catch around server job spawn. This fixes bug where crafty would not gracefully handle if java did not exist. --- app/classes/shared/server.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/classes/shared/server.py b/app/classes/shared/server.py index 15664ce8..f31e02a5 100644 --- a/app/classes/shared/server.py +++ b/app/classes/shared/server.py @@ -137,7 +137,11 @@ class Server: logger.info("Linux Detected") logger.info("Starting server in {p} with command: {c}".format(p=self.server_path, c=self.server_command)) - self.process = pexpect.spawn(self.server_command, cwd=self.server_path, timeout=None, encoding=None) + try: + self.process = pexpect.spawn(self.server_command, cwd=self.server_path, timeout=None, encoding=None) + except Exception as ex: + logger.error("Server {} failed to start with error code: {}".format(self.name, ex)) + return False self.is_crashed = False ts = time.time()