Add terminal catches for server stop command and restart command in crafty's terminal

This commit is contained in:
Andrew 2022-01-18 15:42:26 -05:00
parent b368246614
commit 2d169e8f97
2 changed files with 8 additions and 8 deletions

View File

@ -386,14 +386,6 @@ class Server:
if not self.check_running() and command.lower() != 'start':
logger.warning("Server not running, unable to send command \"{}\"".format(command))
return False
elif command.lower() == self.settings['stop_command']:
logger.info("Stop command detected as terminal input - intercepting. Starting Crafty's stop process for server with id: {}.".format(self.server_id))
self.stop_threaded_server()
return
elif command.lower() == 'restart':
logger.info("Restart command detected as terminal input - intercepting. Starting Crafty's restart process for server with id: {}".format(self.server_id))
self.restart_threaded_server()
return
console.info("COMMAND TIME: {}".format(command))
logger.debug("Sending command {} to server".format(command))

View File

@ -199,6 +199,14 @@ class AjaxHandler(BaseHandler):
srv_obj = self.controller.get_server_obj(server_id)
if command == srv_obj.settings['stop_command']:
logger.info("Stop command detected as terminal input - intercepting. Starting Crafty's stop process for server with id: {}.".format(server_id))
self.controller.management.send_command(exec_user['user_id'], server_id, self.get_remote_ip(), 'stop_server')
command = None
elif command == 'restart':
logger.info("Restart command detected as terminal input - intercepting. Starting Crafty's stop process for server with id: {}.".format(server_id))
self.controller.management.send_command(exec_user['user_id'], server_id, self.get_remote_ip(), 'restart_server')
command = None
if command:
if srv_obj.check_running():
srv_obj.send_command(command)