mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
Merge branch 'pretzel-branch' into 'dev'
If you want to start a server...or stop it... or send any command you should... See merge request crafty-controller/crafty-commander!135
This commit is contained in:
commit
7e6aa8c817
@ -45,6 +45,7 @@ class Management_Controller:
|
|||||||
# Example: Admin issued command start_server for server Survival
|
# Example: Admin issued command start_server for server Survival
|
||||||
management_helper.add_to_audit_log(user_id, "issued command {} for server {}".format(command, server_name),
|
management_helper.add_to_audit_log(user_id, "issued command {} for server {}".format(command, server_name),
|
||||||
server_id, remote_ip)
|
server_id, remote_ip)
|
||||||
|
management_helper.add_command(server_id, user_id, remote_ip, command)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def mark_command_complete(command_id=None):
|
def mark_command_complete(command_id=None):
|
||||||
|
@ -156,7 +156,7 @@ class helpers_management:
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def get_unactioned_commands():
|
def get_unactioned_commands():
|
||||||
query = Commands.select().where(Commands.executed == 0)
|
query = Commands.select().where(Commands.executed == 0)
|
||||||
return db_helper.return_rows(query)
|
return query
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def mark_command_complete(command_id=None):
|
def mark_command_complete(command_id=None):
|
||||||
|
@ -386,14 +386,6 @@ class Server:
|
|||||||
if not self.check_running() and command.lower() != 'start':
|
if not self.check_running() and command.lower() != 'start':
|
||||||
logger.warning("Server not running, unable to send command \"{}\"".format(command))
|
logger.warning("Server not running, unable to send command \"{}\"".format(command))
|
||||||
return False
|
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))
|
console.info("COMMAND TIME: {}".format(command))
|
||||||
logger.debug("Sending command {} to server".format(command))
|
logger.debug("Sending command {} to server".format(command))
|
||||||
|
|
||||||
@ -484,7 +476,7 @@ class Server:
|
|||||||
def remove_watcher_thread(self):
|
def remove_watcher_thread(self):
|
||||||
logger.info("Removing old crash detection watcher thread")
|
logger.info("Removing old crash detection watcher thread")
|
||||||
console.info("Removing old crash detection watcher thread")
|
console.info("Removing old crash detection watcher thread")
|
||||||
schedule.clear(self.name)
|
self.crash_watcher_schedule.remove(self.server_name)
|
||||||
|
|
||||||
def agree_eula(self, user_id):
|
def agree_eula(self, user_id):
|
||||||
file = os.path.join(self.server_path, 'eula.txt')
|
file = os.path.join(self.server_path, 'eula.txt')
|
||||||
|
@ -85,9 +85,14 @@ class TasksManager:
|
|||||||
# select any commands waiting to be processed
|
# select any commands waiting to be processed
|
||||||
commands = management_helper.get_unactioned_commands()
|
commands = management_helper.get_unactioned_commands()
|
||||||
for c in commands:
|
for c in commands:
|
||||||
svr = self.controller.get_server_obj(c['server_id']['server_id'])
|
try:
|
||||||
user_id = c.get('user')['user_id']
|
svr = self.controller.get_server_obj(c.server_id)
|
||||||
command = c.get('command', None)
|
except:
|
||||||
|
logger.error("Server value requested does note exist purging item from waiting commands.")
|
||||||
|
management_helper.mark_command_complete(c.command_id)
|
||||||
|
|
||||||
|
user_id = c.user_id
|
||||||
|
command = c.command
|
||||||
|
|
||||||
if command == 'start_server':
|
if command == 'start_server':
|
||||||
svr.run_threaded_server(user_id)
|
svr.run_threaded_server(user_id)
|
||||||
@ -105,7 +110,7 @@ class TasksManager:
|
|||||||
svr.jar_update()
|
svr.jar_update()
|
||||||
else:
|
else:
|
||||||
svr.send_command(command)
|
svr.send_command(command)
|
||||||
management_helper.mark_command_complete(c.get('command_id', None))
|
management_helper.mark_command_complete(c.command_id)
|
||||||
|
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|
||||||
|
@ -199,6 +199,14 @@ class AjaxHandler(BaseHandler):
|
|||||||
|
|
||||||
srv_obj = self.controller.get_server_obj(server_id)
|
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 command:
|
||||||
if srv_obj.check_running():
|
if srv_obj.check_running():
|
||||||
srv_obj.send_command(command)
|
srv_obj.send_command(command)
|
||||||
|
Loading…
Reference in New Issue
Block a user