diff --git a/app/classes/shared/main_controller.py b/app/classes/shared/main_controller.py index 7dc4c892..5403dbbb 100644 --- a/app/classes/shared/main_controller.py +++ b/app/classes/shared/main_controller.py @@ -175,7 +175,7 @@ class Controller: tempZipStorage += '.zip' websocket_helper.broadcast_user(exec_user['user_id'], 'send_logs_bootbox', { }) - + self.users.set_support_path(exec_user['user_id'], tempZipStorage) @staticmethod @@ -287,9 +287,9 @@ class Controller: return False if helper.is_os_windows(): - server_command = 'java -Xms{}M -Xmx{}M -jar {} nogui'.format(helper.float_to_string(min_mem), + server_command = 'java -Xms{}M -Xmx{}M -jar "{}" nogui'.format(helper.float_to_string(min_mem), helper.float_to_string(max_mem), - '"'+full_jar_path+'"') + full_jar_path) else: server_command = 'java -Xms{}M -Xmx{}M -jar {} nogui'.format(helper.float_to_string(min_mem), helper.float_to_string(max_mem), @@ -471,7 +471,7 @@ class Controller: if helper.check_path_exists(self.servers.get_server_data_by_id(server_id)['backup_path']): shutil.rmtree(helper.get_os_understandable_path(self.servers.get_server_data_by_id(server_id)['backup_path'])) - + #Cleanup scheduled tasks try: helpers_management.delete_scheduled_task_by_server(server_id) diff --git a/app/classes/shared/tasks.py b/app/classes/shared/tasks.py index d35379ea..810703d3 100644 --- a/app/classes/shared/tasks.py +++ b/app/classes/shared/tasks.py @@ -1,4 +1,5 @@ from datetime import timedelta +from http import server import os import sys import json @@ -80,7 +81,7 @@ class TasksManager: logger.info("Reload from DB called. Current enabled schedules: ") for item in jobs: logger.info("JOB: {}".format(item)) - + def command_watcher(self): while True: # select any commands waiting to be processed @@ -285,8 +286,7 @@ class TasksManager: logger.info("Scheduling Serverjars.com cache refresh service every 12 hours") self.scheduler.add_job(server_jar_obj.refresh_cache, 'interval', hours=12, id="serverjars") - @staticmethod - def realtime(): + def realtime(self): loop = asyncio.new_event_loop() asyncio.set_event_loop(loop) @@ -311,7 +311,69 @@ class TasksManager: 'mem_percent': host_stats.get('mem_percent'), 'mem_usage': host_stats.get('mem_usage') }) - time.sleep(4) + + servers = self.controller.servers_list + servers_ping = [] + for srv in servers: + server_data = srv.get('server_data_obj', False) + if server_data: + server_id = server_data.get('server_id', False) + srv['raw_ping_result'] = self.controller.stats.get_raw_server_stats(server_id) + if ("{}".format(srv['raw_ping_result'].get('icon')) == "b''"): + srv['raw_ping_result']['icon'] = False + + servers_ping.append({ + 'id': srv['raw_ping_result'].get('id'), + 'started': srv['raw_ping_result'].get('started'), + 'running': srv['raw_ping_result'].get('running'), + 'cpu': srv['raw_ping_result'].get('cpu'), + 'mem': srv['raw_ping_result'].get('mem'), + 'mem_percent': srv['raw_ping_result'].get('mem_percent'), + 'world_name': srv['raw_ping_result'].get('world_name'), + 'world_size': srv['raw_ping_result'].get('world_size'), + 'server_port': srv['raw_ping_result'].get('server_port'), + 'int_ping_results': srv['raw_ping_result'].get('int_ping_results'), + 'online': srv['raw_ping_result'].get('online'), + 'max': srv['raw_ping_result'].get('max'), + 'players': srv['raw_ping_result'].get('players'), + 'desc': srv['raw_ping_result'].get('desc'), + 'version': srv['raw_ping_result'].get('version'), + 'icon': srv['raw_ping_result'].get('icon') + }) + if (len(websocket_helper.clients) > 0): + websocket_helper.broadcast_page_params( + '/panel/server_detail', + { + 'id': str(server_id) + }, + 'update_server_details', + { + 'id': srv['raw_ping_result'].get('id'), + 'started': srv['raw_ping_result'].get('started'), + 'running': srv['raw_ping_result'].get('running'), + 'cpu': srv['raw_ping_result'].get('cpu'), + 'mem': srv['raw_ping_result'].get('mem'), + 'mem_percent': srv['raw_ping_result'].get('mem_percent'), + 'world_name': srv['raw_ping_result'].get('world_name'), + 'world_size': srv['raw_ping_result'].get('world_size'), + 'server_port': srv['raw_ping_result'].get('server_port'), + 'int_ping_results': srv['raw_ping_result'].get('int_ping_results'), + 'online': srv['raw_ping_result'].get('online'), + 'max': srv['raw_ping_result'].get('max'), + 'players': srv['raw_ping_result'].get('players'), + 'desc': srv['raw_ping_result'].get('desc'), + 'version': srv['raw_ping_result'].get('version'), + 'icon': srv['raw_ping_result'].get('icon') + } + ) + + if (len(servers_ping) > 0) & (len(websocket_helper.clients) > 0): + try: + websocket_helper.broadcast_page('/panel/dashboard', 'update_server_status', servers_ping) + websocket_helper.broadcast_page('/status', 'update_server_status', servers_ping) + except: + console.warning("Can't broadcast server status to websocket") + time.sleep(5) def log_watcher(self): self.controller.servers.check_for_old_logs() diff --git a/app/frontend/templates/base.html b/app/frontend/templates/base.html index ab6d5656..b70091b4 100644 --- a/app/frontend/templates/base.html +++ b/app/frontend/templates/base.html @@ -1,153 +1,162 @@ - - - - - {% block meta %}{% end %} - {% block title %}{{ _('Default') }}{% end %} - - - - - - - - - + + + + + {% block meta %}{% end %} + {% block title %}{{ _('Default') }}{% end %} - + + + + + + + + + - - - - + - - - + + + + - - - + + + - + + + - -
- - + + {% include main_menu.html %} + +
+ +
+ +
+ + {% block content %} + {% end %} + + {% include footer.html %} +
+ + +
+ + - -
+ +
- - - - - - + + + + + + + - - + {% block js %} + + + {% end %} - {% block js %} - - - {% end %} + - \ No newline at end of file diff --git a/app/frontend/templates/blank_page_template.html b/app/frontend/templates/blank_page_template.html index c3ddab33..26e22ecf 100644 --- a/app/frontend/templates/blank_page_template.html +++ b/app/frontend/templates/blank_page_template.html @@ -1,7 +1,6 @@ {% extends ../base.html %} {% block meta %} - {% end %} {% block title %}Crafty Controller - Blank Page{% end %} diff --git a/app/frontend/templates/panel/activity_logs.html b/app/frontend/templates/panel/activity_logs.html index 547ef620..c8717f38 100644 --- a/app/frontend/templates/panel/activity_logs.html +++ b/app/frontend/templates/panel/activity_logs.html @@ -1,8 +1,6 @@ {% extends ../base.html %} {% block meta %} - - {% end %} {% block title %}Crafty Controller - Activity Logs{% end %} @@ -93,7 +91,7 @@ $( document ).ready(function() { if($(window).width() < 1000){ $('.too_small').popover("show"); } - + }); $(window).ready(function(){ $('body').click(function(){ diff --git a/app/frontend/templates/panel/contribute.html b/app/frontend/templates/panel/contribute.html index 5ca38c6b..94efdcba 100644 --- a/app/frontend/templates/panel/contribute.html +++ b/app/frontend/templates/panel/contribute.html @@ -1,7 +1,6 @@ {% extends ../base.html %} {% block meta %} - {% end %} {% block title %}Crafty Controller - Contribute{% end %} @@ -73,7 +72,7 @@

- Thank you for your interest in contributing to Aracdia Technology's Crafty Controller. + Thank you for your interest in contributing to Aracdia Technology's Crafty Controller. We are always thinking of new ways for our community to contribute to this awesome project.

If you don't see a contribution method that peaks your interest now please check back soon.

diff --git a/app/frontend/templates/panel/credits.html b/app/frontend/templates/panel/credits.html index e35abd34..fb5a4ad2 100644 --- a/app/frontend/templates/panel/credits.html +++ b/app/frontend/templates/panel/credits.html @@ -1,7 +1,6 @@ {% extends ../base.html %} {% block meta %} - {% end %} {% block title %}Crafty Controller - Credits{% end %} diff --git a/app/frontend/templates/panel/dashboard.html b/app/frontend/templates/panel/dashboard.html index 0b584423..80da1deb 100644 --- a/app/frontend/templates/panel/dashboard.html +++ b/app/frontend/templates/panel/dashboard.html @@ -1,7 +1,6 @@ {% extends ../base.html %} {% block meta %} - {% end %} {% block title %}Crafty Controller - {{ translate('dashboard', 'dashboard', data['lang']) }}{% end %} @@ -10,7 +9,7 @@
- +